Type | Description | |||
Index as Long | A long expression that specifies the index of item. | |||
ColIndex as Variant | A long expression that specifies the index of column, a string expression that identifies the column's caption or column's key. | |||
IFontDisp | A Font object being used by the cell. |
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 CaptionFormat 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.
The following VB sample changes the font for the focused cell:
List1.BeginUpdate With List1.Items .CellFont(.FocusItem, 0) = List1.Font With .CellFont(.FocusItem, 0) .Name = "Comic Sans MS" .Size = 10 .Bold = True End With End With List1.EndUpdate
The following C++ sample changes the font for the focused cell:
#include "Items.h" #include "Font.h" m_list.BeginUpdate(); CItems items = m_list.GetItems(); long nItem = items.GetFocusItem(); COleVariant vtColumn( (long)0 ); items.SetCellFont( nItem, vtColumn, m_list.GetFont().m_lpDispatch ); COleFont font = items.GetCellFont( nItem, vtColumn ); font.SetName( "Comic Sans MS" ); font.SetBold( TRUE ); m_list.EndUpdate();
The following VB.NET sample changes the font for the focused cell:
AxList1.BeginUpdate() With AxList1.Items .CellFont(.FocusItem, 0) = IFDH.GetIFontDisp(AxList1.Font) With .CellFont(.FocusItem, 0) .Name = "Comic Sans MS" .Bold = True End With End With AxList1.EndUpdate()
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:
axList1.BeginUpdate(); axList1.Items.set_CellFont(axList1.Items.FocusItem, 0, IFDH.GetIFontDisp(axList1.Font)); stdole.IFontDisp spFont = axList1.Items.get_CellFont(axList1.Items.FocusItem, 0); spFont.Name = "Comic Sans MS"; spFont.Bold = true; axList1.EndUpdate();
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:
thisform.List1.Object.BeginUpdate() with thisform.List1.Items .CellFont(.FocusItem,0) = thisform.List1.Font with .CellFont(.FocusItem,0) .Name = "Comic Sans MS" .Bold = .t. endwith endwith thisform.List1.Object.EndUpdate()