Column Size in Datagrid

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
 
A

Aflava

Hi,

Are you talking about a DataGrid or a DataGridView?
You have a Width property for DataGridViewColumn (and should be the same for
datagrid).
 
J

Jennifer Hinojosa

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
 

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