Datagrid Sizing

  • Thread starter Thread starter Helen Trim
  • Start date Start date
H

Helen Trim

How can I set the sizes of columns in a datagrid?

Thanks in advance
Helen
 
Use a DataGridTableStyle object:
' Create new Table Style.
Dim ts As New DataGridTableStyle' Allocate it a mapping namets.MappingName =
"Person" ' Note this is the same name as the Table' Get rid of the default
TableStyleDataGrid1.TableStyles.Clear()' Add this Style to the
CollectionDataGrid1.TableStyles.Add(ts)' Assign New Widths to DataGrid
columns.With DataGrid1.TableStyles("Person") ' Now set the values for this
Style.GridColumnStyles(0).Width = 75 ' First column,
width.GridColumnStyles(1).Width = 25 ' Second
column.GridColumnStyles(2).Width = 75End With
 
Thanks, that works.

Helen
-----Original Message-----
Use a DataGridTableStyle object:
' Create new Table Style.
Dim ts As New DataGridTableStyle' Allocate it a mapping namets.MappingName =
"Person" ' Note this is the same name as the Table' Get rid of the default
TableStyleDataGrid1.TableStyles.Clear()' Add this Style to the
CollectionDataGrid1.TableStyles.Add(ts)' Assign New Widths to DataGrid
columns.With DataGrid1.TableStyles("Person") ' Now set the values for this
Style.GridColumnStyles(0).Width = 75 ' First column,
width.GridColumnStyles(1).Width = 25 ' Second
column.GridColumnStyles(2).Width = 75End With




.
 

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

Similar Threads

Form Autosize 2
Editing Datagrids 4
2003 Datagrid and beyond 2
Datagrid colums auto-size 4
Best way to show mulitple column data 2
DatagridView unbound Column 3
Datagrid column sizing 2
Q: DataGrid Select 4

Back
Top