property Items.ItemBackColor(Item as HITEM) as Color

Retrieves or sets a background color for a specific item.

 TypeDescription 
   Item as HITEM A long expression that indicates the item's handle.  
   Color A color expression that indicates the item's background color.  
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. 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 item's appearance. The sample uses the "".

With Grid1
    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_grid.GetVisualAppearance().Add( 0x50, COleVariant(_T("D:\\Temp\\ExGrid.Help\\item.ebn")) );
m_grid.GetItems().SetItemBackColor( m_grid.GetItems().GetFirstVisibleItem() , 0x50000000 );

The following VB.NET sample changes the item's appearance:

With AxGrid1
    With .VisualAppearance
        .Add(&H50, "D:\Temp\ExGrid.Help\item.ebn")
    End With
    With .Items
        .ItemBackColor(.FirstVisibleItem) = &H50000000
    End With
End With

The following C# sample changes the item's appearance:

axGrid1.VisualAppearance.Add(0x50, "D:\\Temp\\ExGrid.Help\\item.ebn");
axGrid1.Items.set_ItemBackColor(axGrid1.Items.FirstVisibleItem, 0x50000000);

The following VFP sample changes the item's appearance:

With thisform.Grid1
    With .VisualAppearance
        .Add(80, "D:\Temp\ExGrid.Help\item.ebn")
    EndWith
    with .Items
    	.DefaultItem = .FirstVisibleItem
    	.ItemBackColor(0) = 1342177280
    endwith
EndWith

where the 1342177280 value represents the 0x50000000 hexa value.

In VB.NET or C# you require the following functions until the .NET framework will provide:

You can use the following VB.NET function:
     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 
You can use the following C# 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 background color for the focused item:

axGrid1.Items.set_ItemBackColor(axGrid1.Items.FocusItem, ToUInt32(Color.Red) );

The following VB.NET sample changes the background color for the focused item:

With AxGrid1.Items
    .ItemBackColor(.FocusItem) = ToUInt32(Color.Red)
End With

The following VB sample changes the background color for the focused item:

With Grid1.Items
    .ItemBackColor(.FocusItem) = vbRed
End With

The following C++ sample changes the background color for the focused item:

#include "Items.h"
CItems items = m_grid.GetItems();
items.SetItemBackColor( items.GetFocusItem(), RGB(255,0,0) );

The following VFP sample changes the background color for the focused item:

with thisform.Grid1.Items
	.DefaultItem = .FocusItem
	.ItemBackColor( 0 ) = RGB(255,0,0)
endwith

Use the following VB sample to change the background color for the first column when adding new items:

Private Sub Grid1_AddItem(ByVal Item As EXGRIDLibCtl.HITEM)
    Grid1.Items.CellBackColor(Item, o) = vbBlue
End Sub

Send comments on this topic.
1999-2017 Exontrol.COM, Software. All rights reserved.