CellBackColor, CellForeColor

Returns or sets the background and foreground colors of individual cells or ranges of cells. Not available at design time.

Syntax

object.CellBackColor [= color ]

object.CellForeColor [= color ]

The CellBackColor and CellForeColor properties syntax has these parts:

Part Description
object An object expression that evaluates to an object.
color Integer (enumerated). A numeric expression specifying the color for the current cell selection. Setting either of these properties to zero paints the cell using standard background and foreground colors.

Remarks

Changing this property affects the current cell or the current selection, depending on the setting of the FillStyle property.

Setting either of these properties to zero causes the Grid control to paint the cell using the standard background and foreground colors. If you want to set either of these properties to black, set them to one instead of zero.

When working with color, it is important to keep in mind how color appears when viewed on a grayscale device. The following table shows how the 16-color palette translates to four grays.

Color Red Green Blue Gray conversion
Black 0 0 0 Black
White 255 255 255 White
Dark gray 128 128 128 Dark gray
Light gray 192 192 192 Light gray
Dark red 128 0 0 Black
Red 255 0 0 Dark gray
Dark yellow 128 128 0 Dark gray
Yellow 255 255 0 Light gray
Dark green 0 128 0 Black
Green 0 255 0 Dark gray
Dark cyan 0 128 128 Dark gray
Cyan 0 255 255 Light gray
Dark blue 0 0 128 Black
Blue 0 0 255 Dark gray
Dark magenta 128 0 128 Dark gray
Magenta 255 0 255 Light gray