Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleUse a FlexGrid control as a list holding pictures and text
KeywordsFlexGrid, grid, list, picture
CategoriesControls
 
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
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated