Share via


CellBackColor, CellForeColor Properties (ModHFGrid)

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

CellBackColor returns or sets the background colors of individual cells or cell ranges.

CellForeColor returns or sets the foreground colors of individual cells or cell ranges.

These properties are not available at design time.

Syntax

object.CellBackColor [=color]
object.CellForeColor [=color]

Syntax for the CellBackColor and CellForeColor properties has these parts:

Part Description
object An object expression that evaluates to the ModHFGrid Control object.
color Integer (enumerated). A numeric expression that specifies the color for the current cell selection. Setting either of these properties to 0 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 0 causes ModHFGrid to paint the cell using the standard background and foreground colors. If you want to set either of these properties to black, set it to 1 instead of 0.

To set the colors of various ModHFGrid elements, use the BackColorBkg, BackColorFixed, BackColorSel, ForeColorFixed, and ForeColorSel properties. To set all non-fixed cells to the same background color, use the BackColor property.

Example

The following example uses the CellBackColor and CellForeColor properties in ModHFGrid. It resets the background and text colors of the focused cell randomly twice each second for the ModHFGrid. To use this example, paste the following code into the Declarations section of a form with a Timer control and a ModHFGrid with the names Timer1 and ModHFGrid1 respectively, and then load the form.

Private Sub Form_Load ()
   Timer1.Interval =500
   ModHFGrid1.Text ="Focus Here"
End Sub

Private Sub Timer1_Timer ()
   ModHFGrid1.CellBackColor =QBColor(Rnd * 15)
   ModHFGrid1.CellForeColor =QBColor(Rnd * 10)
End Sub

See Also

ModHFGrid Control