CodeItBetter Programming Another VB Programming Blog

How to Resize the columns of a flexgrid at runtime to fit the values to be displayed

Posted on January 5, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'Controls - How to Resize the columns of a flexgrid at runtime to fit the values to be displayed
Option Explicit
 
Public Sub ResizeFlexGrid(grd As MSFlexGrid)
    Dim iRow As Integer
    Dim iCol As Integer
    Dim Max_Len As Single
    Dim New_Len As Single
    Font.Name = grd.Font.Name
    Font.Size = grd.Font.Size
    For iCol = 0 To grd.Cols - 1
        Max_Len = 0
        For iRow = 0 To grd.Rows - 1
            New_Len = TextWidth(grd.TextMatrix(iRow, iCol))
            If Max_Len < New_Len Then Max_Len = New_Len
        Next iRow
        grd.ColWidth(iCol) = Max_Len + 240
        grd.ColAlignment(iCol) = flexAlignLeftCenter
    Next iCol
    grd.AllowUserResizing = flexResizeBoth
End Sub
Filed under: Controls Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.