Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid vb.net 2003

Status
Not open for further replies.

jrprogr

Programmer
Joined
Jul 20, 2006
Messages
74
Location
US
How do i programmatically set the column width of the datagrid..
 
how do i change columns width in the datagrid..
 
You define a DataGridTableStyle and do it there:

Dim ts As DataGridTableStyle = New DataGridTableStyle

DataGrid1.TableStyles.Add(ts)

ts.MappingName = "<Your table name here>"

DataGrid1.TableStyles(0).GridColumnStyles(0).Width = 200



Note that in this line:

ts.MappingName = "<Your table name here>"

the "<Your table name here>" portion should be the name you gave the table when it was filled. For example, if you filled your table like so:

DataAdapter1.Fill(DataTable1, "MyTable")

the line would be:

ts.MappingName = "MyTable"



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top