Retrieves or sets a background color for a specific item.
Type | Description | |||
Item as HITEM | A long expression that indicates the handle of the item. If the Item is 0, the ItemBackColor changes the background color for all items. | |||
Color | A color expression that indicates the item's background color. The last 7 bits in the high significant byte of the color to indicates the identifier of the skin being used. Use the Add method to add new skins to the control. If you need to remove the skin appearance from a part of the control you need to reset the last 7 bits in the high significant byte of the color being applied to the background's part. |
Use the CellBackColor property to change the cell's background color. To change the background color of the entire control you can call BackColor property of the control. Use the ClearItemBackColor property to clear the item's background color, after setting using the ItemBackColor property. Use the SelBackColor property to change appearance for the selected items. The HTML colors are not applied if the item is selected. Use the SelectedItem property to specify whether an item is selected or unselected. Use the Add method to add new skins to the control. You can define new skins and to use it to mark some items, like in the following samples.
The following VB sample changes the item's appearance. The sample uses the "".
With Tree1 With .VisualAppearance .Add &H50, App.Path + "\item.ebn" End With With .Items .ItemBackColor(.FirstVisibleItem) = &H50000000 End With End With
The following C++ sample changes the item's appearance:
#include "Appearance.h" #include "Items.h" m_tree.GetVisualAppearance().Add( 0x50, COleVariant(_T("D:\\Temp\\ExTree.Help\\item.ebn")) ); m_tree.GetItems().SetItemBackColor( m_tree.GetItems().GetFirstVisibleItem() , 0x50000000 );
The following VB.NET sample changes the item's appearance:
With AxTree1 With .VisualAppearance .Add(&H50, "D:\Temp\ExTree.Help\item.ebn") End With With .Items .ItemBackColor(.FirstVisibleItem) = &H50000000 End With End With
The following C# sample changes the item's appearance:
axTree1.VisualAppearance.Add(0x50, "D:\\Temp\\ExTree.Help\\item.ebn"); axTree1.Items.set_ItemBackColor(axTree1.Items.FirstVisibleItem, 0x50000000);
The following VFP sample changes the item's appearance:
With thisform.Tree1 With .VisualAppearance .Add(80, "D:\Temp\ExTree.Help\item.ebn") EndWith with .Items .DefaultItem = .FirstVisibleItem .ItemBackColor(0) = 1342177280 endwith EndWith
where the 1342177280 value represents the 0x50000000 hexa value.
The following C# sample changes the background color for the focused item:
axTree1.Items.set_ItemBackColor(axTree1.Items.FocusItem, ToUInt32(Color.Red) );
where the ToUInt32 function converts a Color expression to an OLE_COLOR expression:
private UInt32 ToUInt32(Color c) { long i; i = c.R; i = i + 256 * c.G; i = i + 256 * 256 * c.B; return Convert.ToUInt32(i); }
The following VB.NET sample changes the background color for the focused item:
With AxTree1.Items .ItemBackColor(.FocusItem) = ToUInt32(Color.Red) End With
where the ToUInt32 function converts a Color expression to an OLE_COLOR expression:
Shared Function ToUInt32(ByVal c As Color) As UInt32 Dim i As Long i = c.R i = i + 256 * c.G i = i + 256 * 256 * c.B ToUInt32 = Convert.ToUInt32(i) End Function
The following C++ sample changes the background color for the focused item:
#include "Items.h" CItems items = m_tree.GetItems(); items.SetItemBackColor( items.GetFocusItem(), RGB(255,0,0) );
The following VFP sample changes the background color for the focused item:
with thisform.Tree1.Items .DefaultItem = .FocusItem .ItemBackColor( 0 ) = RGB(255,0,0) endwith
Use the following VB sample changes the background color for the cells in the first column, when adding new items:
Private Sub Tree1_AddItem(ByVal Item As EXTREELibCtl.HITEM) Tree1.Items.CellBackColor(Item, o) = vbBlue End Sub