

| Type | Description | |||
| Item as HITEM | A long expression that indicates the item's handle. | |||
| IFontDisp | A font object being used. |
By default, the ItemFont property is nothing. If the ItemFont property is nothing, the item uses the control's font. Use the ItemFont property to define a different font for the item. 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 CellCaptionFormat to specify different font attributes. Use the ItemHeight property to specify the height of the item. 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 item:
ComboBox1.BeginUpdate
With ComboBox1.Items
.ItemFont(.FocusItem) = ComboBox1.Font
With .ItemFont(.FocusItem)
.Name = "Comic Sans MS"
.Bold = True
End With
End With
ComboBox1.EndUpdate
The following C++ sample changes the font for the focused item:
#include "Items.h" #include "Font.h" CItems items = m_combobox.GetItems(); m_combobox.BeginUpdate(); items.SetItemFont( items.GetFocusItem(), m_combobox.GetFont().m_lpDispatch ); COleFont font = items.GetItemFont( items.GetFocusItem() ); font.SetName( "Comic Sans MS" ); font.SetBold( TRUE ); m_combobox.EndUpdate();
The following VB.NET sample changes the font for the focused item:
AxComboBox1.BeginUpdate()
With AxComboBox1.Items
.ItemFont(.FocusItem) = IFDH.GetIFontDisp(AxComboBox1.Font)
With .ItemFont(.FocusItem)
.Name = "Comic Sans MS"
.Bold = True
End With
End With
AxComboBox1.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 item:
axComboBox1.BeginUpdate(); axComboBox1.Items.set_ItemFont(axComboBox1.Items.FocusItem, IFDH.GetIFontDisp(axComboBox1.Font)); stdole.IFontDisp spFont = axComboBox1.Items.get_ItemFont(axComboBox1.Items.FocusItem); spFont.Name = "Comic Sans MS"; spFont.Bold = true; axComboBox1.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 item:
thisform.ComboBox1.BeginUpdate() with thisform.ComboBox1.Items .DefaultItem = .FocusItem .ItemFont(0) = thisform.ComboBox1.Font with .ItemFont(0) .Name = "Comic Sans MS" .Bold = .t. endwith endwith thisform.ComboBox1.EndUpdate()