Datagrid formatting

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I am binding my datagrid like this;

MyDataGrid.SetDataBinding(ds, "MyTable") ' ds is the dataset

The problem is this bring all fields from the table. How can I restrict some
of the columns from appearing? Also how can I change the order and widths of
the grid columns?

Thanks

Regards
 
Hi John,

This is achieved through usage of the DataGridTableStyle and
DataGridColumnStyle classes. You should create a DataGridTableStyle with
MappingName equal to "MyTable" and tune up table-wide properties like
background color if you need it. Then, add instances of
DataGridTextBoxColumn (or DataGridBoolColumn if you need such type of
column) for the data columns you want to display in order you want them to
display. MappingName property of each of the grid columns should correspond
to the name of the data column in the data table.

More information and examples on this can be found in MSDN Library.
 
Back
Top