Visual Basic: MSFlexGrid/MSHFlexGrid Controls

CellBackColor, CellForeColor Properties Example

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

Note   If you are using the MSFlexGrid, substitute "MSHFlexGrid1" with "MSFlexGrid1."

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

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