quijote_mx 0 Newbie Poster

Hi! I'm using the following code to autosize columns in MSFlexgrod contro,
but it doesn't work properly.

The maximumm width calculated with the code for every cell in a column
is narrower than the requiered width.

I taught it could be related with the scalemode parameter and it is, but
the colwidth property and the scalemode parameter of the form are both
in twips.

What's the problem ?

For j = 0 To MSFlexGrid1.Cols - 1
[INDENT]                     maxWidth = TextWidth(MSFlexGrid1.TextMatrix(0, j))
                     For i = 1 To MSFlexGrid1.Rows - 1
                     If TextWidth(MSFlexGrid1.TextMatrix(i, j)) > maxWidth Then
[INDENT]                     maxWidth = TextWidth(MSFlexGrid1.TextMatrix(i, j))[/INDENT]
                     End If
                     Next i
                     MSFlexGrid1.ColWidth(j) = maxWidth
[/INDENT]                     Next j