how to resize DataGrids automatically?

J

Juan Dent

Hi,

When you use a DataGrid control in Windows.Forms, you can
double click the headers between columns to auto-size the
column to make a good fit for the data present in that
column. This functionality *must* be present
programatically. Does anybody know where it is??

Also, how can one measure the width that the text inside
some particular row/column is taking? MFC had something
like GetTextExtent()...

Thanks,
Juan Dent
 
J

Juan Dent

Thanks. However one thing. There must be a simpler way
because when you double click while pointing the mouse at
the headers, the columns are adjusted automatically. This
must be a method somewhere don't you think?

Second, this does not take into account the size of the
header text.

Thanks again,
Juan Dent
-----Original Message-----
5.48 How can I autosize a column in my datagrid?
http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp
#q877q
 
S

Scot Rose [MSFT]

There is not an exposed method. the method outlined on that site is the best programatic approach that is available. By all means go to the Feedback site and ask for this feature
to be implemented.

http://register.microsoft.com/mswish/suggestion.asp

Want to know more? Check out the MSDN Library at http://msdn.microsoft.com or the Microsoft Knowledge Base at http://support.microsoft.com

Scot Rose, MCSD
Microsoft Visual Basic Developer Support
Email : (e-mail address removed) <Remove word online. from address>

This posting is provided “AS IS”, with no warranties, and confers no rights.




--------------------
Content-Class: urn:content-classes:message
From: "Juan Dent" <[email protected]>
Sender: "Juan Dent" <[email protected]>
References: <[email protected]> <[email protected]>
Subject: Re: how to resize DataGrids automatically?
Date: Tue, 22 Jul 2003 11:51:19 -0700
Lines: 42
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcNQgj06YLRK7FT1RSiGS4d86iT5LA==
Newsgroups: microsoft.public.dotnet.framework.windowsforms
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.windowsforms:48804
NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms

Thanks. However one thing. There must be a simpler way
because when you double click while pointing the mouse at
the headers, the columns are adjusted automatically. This
must be a method somewhere don't you think?

Second, this does not take into account the size of the
header text.

Thanks again,
Juan Dent
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top