Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto Increase Height for Flexgrid

Status
Not open for further replies.

gadgetguy1111

IS-IT--Management
Mar 19, 2002
20
0
0
SG
hello,

I'm populating a recordset to a flexgrid. i have a field in the recordset that occasionally have long values. I'm linking the datasource of the flexgrid to the recordset.

As the column width is fixed, sometimes, these long records get trancuted.

would like to know if anyone knows how to write some codes to automatically adjust the height of a row in a flexgrid based on the length of a field in a recordset.


Thanks.
 
I don't have the code in front of me, but I'm fairly confident that you can do something like the following:

Loop thru the rows in the grid, and extract the value for the column that you are interested in. Set the grid Row and Cell properties to the cell that you are currently looking at. Then set the font parameters for the form to match those of the cell.

Me.FontName = grdGrid.CellFontName
Me.FontBold = grdGrid.CellFontBold

I would set all of the font properties that you have access to. Then take the text from that cell, and run it thru the TextWidth method of the form.

PrintLength = Me.TextWidth (CellTextString)

After you've found the largest width. Set the column width accordingly.

grdGrid.ColWidth(MyColumn) = MaxPrintWidth + 50

I am no sure if its a direct 1 to 1 mapping, but a few tests should clear that up.

Finally, I would rest the form font settings back to their original values.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein


 
another way is to set the controls allow col resize property so that you can resize the col during runtime. this way, you can set the width at startup, but allow the user to resize during runtime. this makes the flex grid not truncate.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top