Type | Description | |||
Item as Variant | A long expression that indicates the item's handle. | |||
ColIndex as Variant |
A long expression that indicates the column's index, or a string expression that indicates the column's caption or the column's key. | |||
IFontDisp | A Font object that indicates the item's font. |
The following VB sample changes the font for the focused cell:
With Grid1.Items .CellFont(.FocusItem, Grid1.FocusColumnIndex) = Grid1.Font With .CellFont(.FocusItem, 0) .Name = "Comic Sans MS" .Size = 10 .Bold = True End With End With Grid1.Refresh
The following C++ sample changes the font for the focused cell:
#include "Items.h" #include "Font.h" CItems items = m_grid.GetItems(); COleVariant vtItem(items.GetFocusItem()), vtColumn( (long)m_grid.GetFocusColumnIndex() ); items.SetCellFont( vtItem, vtColumn, m_grid.GetFont().m_lpDispatch ); COleFont font = items.GetCellFont( vtItem, vtColumn ); font.SetName( "Comic Sans MS" ); font.SetBold( TRUE ); m_grid.Refresh();
The following VB.NET sample changes the font for the focused cell:
With AxGrid1.Items .CellFont(.FocusItem, AxGrid1.FocusColumnIndex) = IFDH.GetIFontDisp(AxGrid1.Font) With .CellFont(.FocusItem, 0) .Name = "Comic Sans MS" .Bold = True End With End With AxGrid1.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:
axGrid1.Items.set_CellFont(axGrid1.Items.FocusItem, axGrid1.FocusColumnIndex , IFDH.GetIFontDisp(axGrid1.Font)); stdole.IFontDisp spFont = axGrid1.Items.get_CellFont(axGrid1.Items.FocusItem, axGrid1.FocusColumnIndex); spFont.Name = "Comic Sans MS"; spFont.Bold = true; axGrid1.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.Grid1.Items .DefaultItem = .FocusItem .CellFont(0,thisform.Grid1.FocusColumnIndex) = thisform.Grid1.Font with .CellFont(0,0) .Name = "Comic Sans MS" .Bold = .t. endwith endwith thisform.Grid1.Object.Refresh()