Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to autosize columns in MSFlexgrid

1 view
Skip to first unread message

Luca Bianchi

unread,
Jan 29, 2000, 3:00:00 AM1/29/00
to
Please,help me!
Thanks.


Kerry Moorman

unread,
Jan 30, 2000, 3:00:00 AM1/30/00
to
Luca,

I don't know of any property that you can set to get the MSFlexgrid to
autosize its columns to the width of the widest cell in the column. But
here is a subprocedure that seems to accomplish the same thing:

Private Sub AutosizeColumns(myGrid As MSFlexGrid)

Dim RowCounter As Long, ColCounter As Long, MaxCellWidth As Single

For ColCounter = 0 To myGrid.Cols - 1
MaxCellWidth = 0
myGrid.Col = ColCounter
For RowCounter = 0 To myGrid.Rows - 1
myGrid.Row = RowCounter
If TextWidth(myGrid.Text) > MaxCellWidth Then
MaxCellWidth = TextWidth(myGrid.Text)
End If
Next RowCounter
'Enforce a minimul column width
If MaxCellWidth = 0 Then MaxCellWidth = 200
'Add a 12% padding to the column width
myGrid.ColWidth(ColCounter) = MaxCellWidth * 1.12
Next ColCounter

End Sub

Send the sub the grid to autosize like this:

AutosizeColumns grdSalesItems

Hope this helps,

Kerry Moorman

Luca Bianchi wrote in message <38933416...@galactica.it>...
>Please,help me!
>Thanks.
>

Mr Todd Hampton

unread,
Feb 11, 2000, 3:00:00 AM2/11/00
to
Very helpful. Does anybody know how to arrange the order of the
columns? I've always had to resort to changing the order of the
fields in the database because I haven't been able to find a way to
display the columns in the order that I want.

Kerry Moorman

unread,
Feb 11, 2000, 3:00:00 AM2/11/00
to
Todd,

When you build your SQL Select string that you will use to open a recordset,
specify the fields you want in the order you want them.

In other words, instead of

Select * From Inventory

use

Select InventoryID, ProductName, Instock From Inventory

Hope this helps,

Kerry Moorman

Mr Todd Hampton wrote in message <38a47fbd....@enews.newsguy.com>...

0 new messages