The following example uses the Styles collection to access each style. It fills the grid with style properties. To try the example, place BeeGrid on a form. Paste the code into the Declarations section and press F5.
Private Sub SGGrid1_OnInit()
Dim sty As SGStyle, i As Integer
Dim lRow As Long
With SGGrid1
.RedrawEnabled = False
.Columns.RemoveAll True
.DataColCount = 22
.DataRowCount = .Styles.Count
'create columns with style properties
.Columns(1).Caption = "Style Name"
.Columns(2).Caption = "Backcolor"
.Columns(3).Caption = "Forecolor"
.Columns(4).Caption = "Base Style"
.Columns(5).Caption = "Font name"
.Columns(6).Caption = "Font size"
.Columns(6).Style.TextAlignment = sgAlignRightCenter
For i = 7 To 10
.Columns(i).Caption = _
Choose(i - 6, "Bold", "Italic", "Underline", "Strikethrough")
.Columns(i).Control.Type = sgCellCheckBox
.Columns(i).Style.TextAlignment = sgAlignCenterCenter
.HeadingTextAlignment = sgAlignCenterCenter
Next
.Columns(11).Caption = "Format"
.Columns(12).Caption = "Appearance"
With .Columns(12).ValueItems
.Add 1, "3D" 'sg3D
.Add 2, "3D Light" 'sg3DLight
End With
.Columns(13).Caption = "DisplayType"
.Columns(13).ValueItems.Add 0, "Text" 'sgDisplayText
.Columns(14).Caption = "TextAlignment"
With .Columns(14).ValueItems
.Add 0, "General" 'sgAlignGeneral
.Add 4, "Left-Center" 'sgAlignLeftCenter
.Add 5, "Center-Center" 'sgAlignCenterCenter
End With
.Columns(15).Caption = "PictureAlignment"
.Columns(15).ValueItems.Add 3, "Left-Center" 'sgPicAlignLeftCenter
.Columns(16).Caption = "Padding"
.Columns(17).Caption = "WordWrap"
.Columns(17).Control.Type = sgCellCheckBox
.Columns(17).Style.TextAlignment = sgAlignCenterCenter
.Columns(18).Caption = "Ellipsis"
.Columns(18).ValueItems.Add 1, "Ellipsis End" 'sgEllipsisEnd
.Columns(19).Caption = "Borders"
With .Columns(19).ValueItems
.Add 15, "All" 'sgCellBorderAll
.Add 0, "No Border" 'sgCellNoBorder
End With
.Columns(20).Caption = "Border Color"
.Columns(21).Caption = "Border Size"
.Columns(22).Caption = "Border Style"
With .Columns(22).ValueItems
.Add 1, "Solid" 'sgCellBorderSolid
End With
End With
'enum styles end show values for each property
For Each sty In SGGrid1.Styles
lRow = lRow + 1
With SGGrid1.Rows.At(lRow)
.Cells(0).Value = sty.Name
.Cells(1).Style.BackColor = sty.BackColor
.Cells(2).Style.BackColor = sty.ForeColor
.Cells(3).Value = sty.BaseStyle
.Cells(4).Value = sty.Font.Name
.Cells(5).Value = sty.Font.Size
.Cells(6).Value = sty.Font.Bold
.Cells(7).Value = sty.Font.Italic
.Cells(8).Value = sty.Font.Underline
.Cells(9).Value = sty.Font.Strikethrough
.Cells(10).Value = sty.Format
.Cells(11).Value = sty.Appearance
.Cells(12).Value = sty.DisplayType
.Cells(13).Value = sty.TextAlignment
.Cells(14).Value = sty.PictureAlignment
.Cells(15).Value = sty.Padding
.Cells(16).Value = sty.WordWrap
.Cells(17).Value = sty.Ellipsis
.Cells(18).Value = sty.Borders
.Cells(19).Style.BackColor = sty.BorderColor
.Cells(20).Value = sty.BorderSize
.Cells(21).Value = sty.BorderStyle
End With
Next
SGGrid1.RedrawEnabled = True
End Sub
Back to topic