|
|
Title | Use a FlexGrid control as a list holding pictures and text |
Keywords | FlexGrid, grid, list, picture |
Categories | Controls |
|
|
Set the control's properties so it behaves more or less like a list. This example uses:
- One row for each item.
- No fixed rows or columns, and no grid lines.
- SelectionMode is flexSelectionByRow so clicking on any cell in a row selects the whole row.
- The row height is 2 pixels taller than the images.
- The first column's width (which holds the pitures) is 2 pixels wider than the images.
|
|
' Load the items.
Private Sub Form_Load()
Const NUM_ROWS = 10
Dim i As Integer
flxItems.Rows = NUM_ROWS
flxItems.Cols = 2
flxItems.FixedRows = 0
flxItems.FixedCols = 0
flxItems.GridLines = flexGridNone
flxItems.SelectionMode = flexSelectionByRow
flxItems.RowHeightMin = imgItems(0).Height + _
ScaleY(2, vbPixels, vbTwips)
flxItems.ColWidth(0) = flxItems.RowHeightMin
flxItems.Width = flxItems.ColWidth(0) + _
flxItems.ColWidth(1) + 400
flxItems.Clear
For i = 1 To NUM_ROWS
flxItems.Row = i - 1
flxItems.Col = 0
Set flxItems.CellPicture = imgItems(CInt(Rnd * _
5)).Picture
flxItems.TextMatrix(i - 1, 1) = "Item " & Format$(i _
- 1)
Next i
End Sub
Private Sub flxItems_DblClick()
MsgBox "Item " & Format$(flxItems.Row) & " selected"
End Sub
|
|
|
|
|
|