Using the TextWidth function in a datagrid

01-14-2005, 08:24 AM
I'm using the TextWidth function to size a column in datagrid. The intention is to resize the column such that it will be just the right length to contain the value (is it called autosizing?).

It doesn't seem to work though. Each time it runs, I resize it to fit the string D:\Source\ABS\SQL\*.sql, but it chops off half the q and all of the l. How can I get around this? :confused:

I did a search and came up with the API function GetTextExtentPoint32, which looks very complicated for such a small thing, so I can't help thinking that there must be an easier way.

01-14-2005, 08:54 AM
I think this has to do with interior of a cell.
Each cell has gridlines and margins to have some space between the gridline and the text.
So you just have to take in account some extra pixels to avoid the column width being to small.
(Add a "Q" to the string when using the .TextWidth() method)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum