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
 
 
 
 
 
TitleCopy array data into a FlexGrid control
KeywordsFlexGrid, array, data
CategoriesTips and Tricks, Software Engineering, Controls
 
The CopyArrayToGrid subroutine loops over the values in the array copying them into the FlexGrid control using its TextMatrix method.
 
' Copy the array data into the grid.
Private Sub CopyArrayToGrid(ByRef m_ArrayData() As String, _
    ByVal grd As MSFlexGrid)
Dim rmin As Integer
Dim cmin As Integer
Dim rmax As Integer
Dim cmax As Integer
Dim r As Integer
Dim c As Integer

    rmin = LBound(m_ArrayData, 1)
    rmax = UBound(m_ArrayData, 1)
    cmin = LBound(m_ArrayData, 2)
    cmax = UBound(m_ArrayData, 2)
    grd.Rows = rmax - rmin + 1
    grd.Cols = cmax - cmin + 1
    grd.FixedCols = 0
    grd.FixedRows = 0

    For r = rmin To rmax
        For c = cmin To cmax
            grd.TextMatrix(r - rmin, c - cmin) = _
                m_ArrayData(r, c)
        Next c
    Next r
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated