Column Size in Datagrid

  • Thread starter Thread starter Jennifer Hinojosa
  • Start date Start date
J

Jennifer Hinojosa

Will someone please help me out by telling me how to set the width of a
column in a datagrid using VB?

Thanks for your help!

Jennifer
 
Hi,

Are you talking about a DataGrid or a DataGridView?
You have a Width property for DataGridViewColumn (and should be the same for
datagrid).
 
I'm talking about a DataGrid in Windows Forms - not a DataGridView.

I've got some code below which doesn't work. It's erroring out on the 2nd
line.

Dim myGridColumns As GridColumnStylesCollection
myGridColumns = dgCustomerList.TableStyles(0).GridColumnStyles
myGridColumns.Item(1).Width = 200
myGridColumns.Item(2).Width = 250
myGridColumns.Item(3).Width = 250
myGridColumns.Item(4).Width = 100
myGridColumns.Item(5).Width = 100
myGridColumns.Item(6).Width = 200
myGridColumns.Item(7).Width = 200
myGridColumns.Item(8).Width = 200
 
Back
Top