Retrieves or sets the cell's foreground color.
Type | Description | |||
Item as Variant | A long expression that indicates the item's handle. | |||
ColIndex as Variant | A long expression that indicates the cell's handle or the column's index, a string expression that indicates the column's caption or the column's key. | |||
Color | A color expression that indicates the cell's foreground color. |
For instance, the following VB code changes the left top cell of your control: ComboBox1.Items.CellForeColor(ComboBox1.Items(0), 0) = vbBlue
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 for the focused cell:
axComboBox1.Items.set_CellForeColor(axComboBox1.Items.FocusItem, 0, ToUInt32(Color.Red) );
The following VB.NET sample changes the foreground color for the focused cell:
With AxComboBox1.Items .CellForeColor(.FocusItem, 0) = ToUInt32(Color.Red) End With
The following C++ sample changes the foreground color for the focused cell:
#include "Items.h" CItems items = m_combobox.GetItems(); items.SetCellForeColor( COleVariant( items.GetFocusItem() ), COleVariant( (long)0 ), RGB(255,0,0) );
The following VFP sample changes the foreground color for the focused cell:
with thisform.ComboBox1.Items .DefaultItem = .FocusItem .CellForeColor( 0, 0 ) = RGB(255,0,0) endwith
For instance, the following code shows how to change the left top cell of your control: ComboBox1.Items.CellForeColor(ComboBox1.Items(0), 0) = vbBlue
Note: The intersection of an item with a column defines a cell. Each cell is uniquely represented by its handle. The cell's handle is of HCELL type, that's equivalent with a long type. All properties of Items object that have two parameters Item and ColIndex, refer a cell.
The following lines are equivalents and each of them changes the bold font attribute of the first cell on the first item.
With ComboBox1 .Items.CellBold(, .Items.ItemCell(.Items(0), 0)) = True .Items.CellBold(.Items(0), 0) = True .Items.CellBold(.Items(0)) = True .Items.CellBold(.Items.ItemByIndex(0)) = True .Items.CellBold(.Items.ItemByIndex(0), 0) = True .Items.CellBold(.Items(0), ComboBox1.Columns(0).Caption) = True End With