VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Auto resize flexgrid column widths

Jonathan W. Lartigue  (1 Submission)   Miscellaneous   Visual Basic 3.0   Beginner   Wed 3rd February 2021

Automatically resize the columns in any flex grid to give a nice, professional appearance.
Public sub automatically resizes MS Flex Grid columns to match the width of the text, no matter the size of the grid or the number of columns.
Reads first n number of rows of data, and adjusts column size to match the widest cell of text. Will even expand columns proportionately if they aren't wide enough to fill out the entire width of the grid. Configurable constraints allow you to designate
1) Any flex grid to resize
2) Maximum column width
3) the maximum number of rows in depth to look for the widest cell of text.

Inputs
msFG (MSFlexGrid) = The name of the flex grid to resize .... MaxRowsToParse (integer) = The maximum number of rows (depth) of the table to scan for cell width (e.g. 50) .... MaxColWidth (Integer) = The maximum width of any given cell in twips (e.g. 5000)

Assumes
Simply drop this public sub into your form or module and access it from anywhere in your program to automatically resize any flex grid.

Rate Auto resize flexgrid column widths (8(8 Vote))
Auto resize flexgrid column widths.bas

Auto resize flexgrid column widths Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters