Autosize Flexgrid Columns
I'd like a large pepperoni pizza... oh wait, no flexgrid. I've got one, just started learning how to use the buggers, they're kinda neat. I'd like to have some code that will make the widths all fit to text. Like when you double click on the resizing bar in most microsoft programs. Any thoughts? Thanks! :)
Re: Autosize Flexgrid Columns
Quote:
Originally Posted by
Serge
Here is a
Generic routine I've put together a while back:
VB Code:
Public Sub ResizeGrid(pGrid As MSFlexGrid, pForm As Form)
Dim intRow As Integer
Dim intCol As Integer
With pGrid
For intCol = 0 To .Cols - 1
For intRow = 0 To .Rows - 1
If .ColWidth(intCol) < pForm.TextWidth(.TextMatrix(intRow, intCol)) + 100 Then
.ColWidth(intCol) = pForm.TextWidth(.TextMatrix(intRow, intCol)) + 100
End If
Next
Next
End With
End Sub
Then just call this routine like this:
ResizeGrid MSFlexGrid1, Form1
For some reason the procedure doesnt seem to recognise my flexigrid. Stepping thru the code it lists my flexigrid as ""
Re: Autosize Flexgrid Columns
There is no reason to ressurrect the dead! This thread is 9 years old. Try the solution linked to in post #2.