Resize DataGrid Control's columns - VB.NET

T

Tom Rahav

Hi!

My question is if it's possible to adjust DataGrid control's columns' width
by code (runtime).
I have a DataGrid control that displays table from dataset that contains two
fields. The first one is just an ID, which is 4 digits long, while the other
field is a long text field. I don't want the user to change it every time
when the form loads, but do it for him by code.

Any idea will be thankful!
Tom Rahav.
 
K

Kevin Yu [MSFT]

Hi Tom,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to control the width of each
column in a DataGrid control. If there is any misunderstanding, please feel
free to let me know.

As far as I know, to control the width of each column, we have to add
TableStyles and GridColumnStyles. We can add a TableStyle for the whole
table and add GridColumnStyles for each column. In the DataGridColumnStyle,
we change the Width property to achieve this.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemwindowsformsdatagridcolumnstyleclasswidthtopic.asp

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

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