The following example fills the grid array with random numbers and creates a StyleCondition for each possible cell value. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.
Private Sub SGGrid1_OnInit()
Dim sStyleName As String
Dim i As Long, j As Long
Dim ar As SGArray
SGGrid1.RedrawEnabled = False
SGGrid1.GroupByBoxVisible = False
'create cols and rows
SGGrid1.DataRowCount = 20
SGGrid1.DataColCount = 3
'create 256 styles
For i = 0 To 255
sStyleName = "Style" & Trim$(i)
With SGGrid1.Styles.Add(sStyleName)
.CopyFrom SGGrid1.Styles("Normal")
.BackColor = RGB(255 - i, 255 - i, 255 - i)
.ForeColor = RGB(255, i, 0)
.Font.Bold = True
End With
'add new style in the StyleConditions collection
SGGrid1.CellStyleConditions.Add _
sStyleName, sgConditionCellValue, sgOpEqual, i
Next
Set ar = SGGrid1.Array
'add test data
For i = 0 To SGGrid1.DataRowCount - 1
For j = 0 To SGGrid1.DataColCount - 1
ar.Value(i, j) = CLng(Rnd * 255)
Next
Next
SGGrid1.RedrawEnabled = True
End Sub
Back to topic