property Grid.ForeColor as Color
Retrieves or sets a value that indicates the control's foreground color.

 TypeDescription 
   Color A color expression that indicates the control's foreground color.  
Use the ForeColor property to set the control's foreground color. If the control contains locked columns, ( if the CountLockedColumns property is grater than 0, a locked column is a column non scrollable ), use the ForeColorLock property to specify the foreground color for locked columns.  Use the CellForeColor property to set the cell's foreground color. Use the ItemForeColor property to specify the item's foreground color. The control highlights the selected items only if the SelBackColor and BackColor properties have different values, and the SelForeColor and ForeColor properties have different values. Use the Def(exCellForeColor) property to change the foreground color for all cells in the column. The SelForeColor property is applied only if it is different that the control's foreground color. 

The following VB sample sets the foreground color for the first column:

With Grid1.Columns(0)
    .Def(exCellForeColor) = RGB(255, 0, 0)
End With

The following C++ sample sets the foreground color for the first column:

#include "Column.h"
#include "Columns.h"
CColumns columns = m_grid.GetColumns();
CColumn column = columns.GetItem( COleVariant( long(0) ) );
column.SetDef(5, COleVariant( (long)RGB(255,0,0 ) ) );

The following VB.NET sample sets the foreground color for the first column:

With AxGrid1.Columns(0)
    .Def(EXGRIDLib.DefColumnEnum.exCellForeColor) = ToUInt32(Color.FromArgb(255, 0, 0))
End With

where the ToUInt32 function converts a Color expression to 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 sets the foreground color for the first column:

axGrid1.Columns[0].set_Def(EXGRIDLib.DefColumnEnum.exCellForeColor, ToUInt32(Color.FromArgb(255, 0, 0))); 

where the ToUInt32 function converts a Color expression to 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 VFP sample sets the foreground color for the first column:

with thisform.Grid1.Columns(0)
	.Def(5) = RGB(255,0,0)
endwith

 


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