Resize DataGrid Control's columns - VB.NET

  • Thread starter Thread starter Tom Rahav
  • Start date Start date
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.
 
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."
 
Back
Top