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
 
 
 
 
 
TitleSave and restore FlexGrid column widths
KeywordsFlexGrid, column width
CategoriesControls
 
Loop through the columns and save their widths in the registry. Then when the program reloads, you can read the values out of the registry and restore them.
 
Private Sub SaveFlexGridColumnWidths(ByVal flx As _
    MSFlexGrid)
Dim i As Integer

    For i = 0 To flx.Cols - 1
        ' Save the column width.
        SaveSetting _
            "SaveFlexWidths", _
            "ColumnWidths", "Col" & Format$(i), _
            flx.ColWidth(i)
    Next i
End Sub

Private Sub LoadFlexGridColumnWidths(ByVal flx As _
    MSFlexGrid)
Dim i As Integer

    For i = 0 To flx.Cols - 1
        ' Get the column width. Use its current
        ' width as the default value.
        flx.ColWidth(i) = GetSetting( _
            "SaveFlexWidths", _
            "ColumnWidths", "Col" & Format$(i), _
            flx.ColWidth(i))
    Next i
End Sub
 
Note that you could just as easily save and restore the widths from a text file.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated