Retrieves or sets a foreground color for a specific item.
Type | Description | |||
Item as HITEM | A long expression that indicates the item's handle. | |||
Color | A color expression that defines the item's foreground color. |
Use the CellForeColor property to change the item's foreground color. Use the ForeColor property to change the control's foreground color. Use the ClearItemForeColor property to clear the item's foreground color. The SelectableItem property specifies whether the user can select an item. 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 foreground color for cells in the first column as user add new items:
Private Sub ComboBox1_AddItem(ByVal Item As EXCOMBOBOXLibCtl.HITEM) ComboBox1.Items.CellForeColor(Item, o) = vbBlue End Sub
In VB.NET or C# you require the following functions until the .NET framework will provide:
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
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 C# sample changes the foreground color of the focused item:
axComboBox1.Items.set_ItemForeColor(axComboBox1.Items.FocusItem, ToUInt32(Color.Red) );
The following VB.NET sample changes the foreground color of the focused item:
With AxComboBox1.Items .ItemForeColor(.FocusItem) = ToUInt32(Color.Red) End With
The following C++ sample changes the foreground color of the focused item:
#include "Items.h" CItems items = m_combobox.GetItems(); items.SetItemForeColor( items.GetFocusItem(), RGB(255,0,0) );
The following VFP sample changes the foreground color of the focused item:
with thisform.ComboBox1.Items .DefaultItem = .FocusItem .ItemForeColor( 0 ) = RGB(255,0,0) endwith