1,105,281 Community Members

change column width in MSFlexgrid

Member Avatar
singoi
Newbie Poster
10 posts since Nov 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi Friends,

how can i change the columns width in MSflexgrid by code from 1.jpg to 2.Jpg

I have copied this code in my Module:


Public Function Grid_AutoSize(oGrid As MSFlexGrid, oLabel As Label)
  Dim nRow As Long
  Dim nCol As Long
  Dim nWidth As Long
  Dim nMaxWidth As Long
 
  ' Setzen der Eigenschaften
  With oLabel
    With .Font
      .Name = oGrid.Font.Name
      .Size = oGrid.Font.Size
      .Bold = oGrid.Font.Bold
      .Italic = oGrid.Font.Italic
      .Strikethrough = oGrid.Font.Strikethrough
      .Underline = oGrid.Font.Underline
    End With
 
    ' Wichtig!
    .WordWrap = False
    .AutoSize = True
  End With
 
  ' Auswerten und Setzen der Grössen
  With oGrid
    For nCol = .FixedCols To .Cols - 1
      nMaxWidth = 0
      For nRow = .FixedRows To .Rows - 1
        oLabel.Caption = .TextMatrix(nRow, nCol)
        nWidth = oLabel.Width
        If nWidth + 100 > nMaxWidth Then nMaxWidth = nWidth + 100
      Next nRow
 
      .ColWidth(nCol) = nMaxWidth
    Next nCol
  End With
End Function

and i have called this function in my Form Load

Grid_AutoSize msf1, lbltemp

Dim m As Long
For m = 1 To msf1.Cols + 1
  msf1.ColWidth(-1) = 1400
Next

can u please help me

Thanks,

Singoi

Attachments 1.jpg 92.53KB 2.jpg 80.42KB
Member Avatar
QVeen72
Veteran Poster
1,016 posts since Nov 2006
Reputation Points: 104 [?]
Q&As Helped to Solve: 164 [?]
Skill Endorsements: 7 [?]
 
0
 

Hi,

Try This :

msf1.ColWidth(0) = 400
msf1.ColWidth(1) = 1000
msf1.ColWidth(2) = 1200
msf1.ColWidth(3) = 1200
msf1.ColWidth(4) = 1500

With a little bit of judgement, you can do it..

Regards
Veena

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article