A DataGrid issue

jango_fett

Member
Joined
Jun 15, 2005
Messages
23
Programming Experience
Beginner
A DataGrid issue [RESOLVED]

HI, all. Though not a favorite of mine, the DaraGrid control is in many cases the ideal control for displaying info. Unfortunately, it doesn't change the fact that it is a royal pain for me to use. So, my question is, is there a way to modify the width of a specific column within a DataGrid during runtime? The problem emerges after I've executed a query and changed the Datasource value, the DataGrid assumes the same width for all its columns. I tried playing with the TableStyles property without any luck. I probably need a point in the right direction. Many thanks.
 
Last edited:
Column Styles

Width is a property of Column Styles, read up on all the stuff you can do with it.

simple example:

Private Sub AddCustomColumnStyle()
' Set the TableStyle Mapping name.
myTableStyle.MappingName = "customerTable"
myTableStyle.BackColor = Color.Pink

' Set the ColumnStyle properties and add to TableStyle.
myColumnStyle.MappingName = "Customers"
myColumnStyle.HeaderText = "Customer Name"
myColumnStyle.Width = 250
myTableStyle.GridColumnStyles.Add(myColumnStyle)
myDataGrid.TableStyles.Add(myTableStyle)
End Sub 'AddCustomColumnStyle


Be sure to set the MappingName...
 
Thanks, DavidT for pointing me to the right direction. I am starting to get acquainted now with the DataGridTableStyle and DataGridColumnStyle classes. I guess I was just used to the DataGrid control from the VB6 era. ;)
You definetely saved me a lot of headaches. Thanks, dude.
 
Back
Top