Type | Description | |||
Item as HITEM | A long expression that specifies the item's handle. | |||
IFontDisp | A Font object that specifies the item's font. |
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 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 item:
With Tree1.Items .ItemFont(.FocusItem) = Tree1.Font With .ItemFont(.FocusItem) .Name = "Comic Sans MS" .Bold = True End With End With Tree1.Refresh
The following C++ sample changes the font for the focused item:
#include "Items.h" #include "Font.h" CItems items = m_tree.GetItems(); items.SetItemFont( items.GetFocusItem(), m_tree.GetFont().m_lpDispatch ); COleFont font = items.GetItemFont( items.GetFocusItem() ); font.SetName( "Comic Sans MS" ); font.SetBold( TRUE ); m_tree.Refresh();
The following VB.NET sample changes the font for the focused item:
With AxTree1.Items .ItemFont(.FocusItem) = IFDH.GetIFontDisp(AxTree1.Font) With .ItemFont(.FocusItem) .Name = "Comic Sans MS" .Bold = True End With End With AxTree1.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 item:
axTree1.Items.set_ItemFont( axTree1.Items.FocusItem, IFDH.GetIFontDisp( axTree1.Font ) ); stdole.IFontDisp spFont = axTree1.Items.get_ItemFont(axTree1.Items.FocusItem ); spFont.Name = "Comic Sans MS"; spFont.Bold = true; axTree1.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 item:
with thisform.Tree1.Items .DefaultItem = .FocusItem .ItemFont(0) = thisform.Tree1.Font with .ItemFont(0) .Name = "Comic Sans MS" .Bold = .t. endwith endwith thisform.Tree1.Object.Refresh()