The following example uses the CellAsPicture property to create pictures for a value items. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.
Private Sub SGGrid1_OnInit()
Dim Row As SGRow, vis As SGValueItems
Dim sColorColKey As String
Dim i As Integer, lRowKey As Long
With SGGrid1
'create rows and cols
.DataRowCount = 16
.DataColCount = 3
.RowNumbering = True
End With
'customize columns
With SGGrid1.Columns
With .At(1)
.HeadingPicture = sgbipFirst + 2
.ReadOnly = True
.AllowSizing = False
.AllowFocus = False
.Style.Borders = sgCellBorderAll
.Style.BorderSize = 3
.Width = 255
sColorColKey = .Key
End With
.At(2).Caption = "Color"
With .At(3)
Set vis = .ValueItems
.Control.Type = sgCellDropDown
.Style.PictureAlignment = sgPicAlignLeftCenter
.Style.DisplayType = sgDisplayPicture
.HeadingStyle.DisplayType = sgDisplayText
.Caption = "Color combo"
End With
End With
For i = 0 To 15
lRowKey = SGGrid1.Rows.At(i + 1).Key
SGGrid1.cell(lRowKey, sColorColKey).Style.BackColor = QBColor(i)
SGGrid1.Array.Value(i, 1) = QBColor(i)
vis.Add QBColor(i), "&H" & _
QBColor(i) & "&", SGGrid1.CellAsPicture(lRowKey, sColorColKey)
Next
Set vis = Nothing
End Sub
Back to topic