Type | Description | |||
Item as Variant | A long expression that indicates the item's handle, or optional if the cell's handle is passed to ColIndex parameter | |||
ColIndex as Variant | A long expression that indicates the column's index or cell's handle, or a string expression that indicates the column's caption. | |||
IFontDisp | A Font object that indicates the cell's font. |
By default, the CellFont property is nothing. If the CellFont property is noting, the cell uses the item's font. Use the CellFont and ItemFont properties to specify different fonts for cells or items. Use the CellBold, CellItalic, CellUnderline, CellStrikeout, ItemBold, ItemUnderline, ItemStrikeout, ItemItalic or CellValueFormat to specify different font attributes. Use the Refresh method to refresh the control's content on the fly. Use the BeginUpdate and EndUpdate methods if you are doing multiple changes, so no need for an update each time a change is done. Use the ConditionalFormats method to apply formats to a cell or range of cells, and have that formatting change depending on the value of the cell or the value of a formula.
The following VB sample changes the font for the focused cell:
With G2antt1.Items .CellFont(.FocusItem, 0) = G2antt1.Font With .CellFont(.FocusItem, 0) .Name = "Comic Sans MS" .Size = 10 .Bold = True End With End With G2antt1.Refresh
The following C++ sample changes the font for the focused cell:
#include "Items.h" #include "Font.h" CItems items = m_g2antt.GetItems(); COleVariant vtItem(items.GetFocusItem()), vtColumn( (long)0 ); items.SetCellFont( vtItem, vtColumn, m_g2antt.GetFont().m_lpDispatch ); COleFont font = items.GetCellFont( vtItem, vtColumn ); font.SetName( "Comic Sans MS" ); font.SetBold( TRUE ); m_g2antt.Refresh();
The following VB.NET sample changes the font for the focused cell:
With AxG2antt1.Items .CellFont(.FocusItem, 0) = IFDH.GetIFontDisp(AxG2antt1.Font) With .CellFont(.FocusItem, 0) .Name = "Comic Sans MS" .Bold = True End With End With AxG2antt1.CtlRefresh()
where the IFDH class is defined like follows:
Public Class IFDH Inherits System.Windows.Forms.AxHost Sub New() MyBase.New("") End Sub Public Shared Function GetIFontDisp(ByVal font As Font) As Object GetIFontDisp = AxHost.GetIFontFromFont(font) End Function End Class
The following C# sample changes the font for the focused cell:
axG2antt1.Items.set_CellFont( axG2antt1.Items.FocusItem, 0, IFDH.GetIFontDisp( axG2antt1.Font ) ); stdole.IFontDisp spFont = axG2antt1.Items.get_CellFont(axG2antt1.Items.FocusItem, 0 ); spFont.Name = "Comic Sans MS"; spFont.Bold = true; axG2antt1.CtlRefresh();
where the IFDH class is defined like follows:
internal class IFDH : System.Windows.Forms.AxHost { public IFDH() : base("") { } public static stdole.IFontDisp GetIFontDisp(System.Drawing.Font font) { return System.Windows.Forms.AxHost.GetIFontFromFont(font) as stdole.IFontDisp; } }
The following VFP sample changes the font for the focused cell:
with thisform.G2antt1.Items .DefaultItem = .FocusItem .CellFont(0,0) = thisform.G2antt1.Font with .CellFont(0,0) .Name = "Comic Sans MS" .Bold = .t. endwith endwith thisform.G2antt1.Object.Refresh()