Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Using the TextWidth function in a datagrid


Reply
 
Thread Tools Display Modes
  #1  
Old 01-14-2005, 08:24 AM
mediaeval's Avatar
mediaeval mediaeval is offline
Centurion
 
Join Date: Sep 2003
Location: The Great Blaskets
Posts: 173
Default Using the TextWidth function in a datagrid


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?

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.
__________________
Son, he said, grab your things, I've come to take you home [Solsbury Hill, Peter Gabriel]
Reply With Quote
  #2  
Old 01-14-2005, 08:54 AM
Flyguy's Avatar
Flyguy Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 18,885
Default

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)
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->