How to setup dynamic GridColumnStyles from a datasource?

  • Thread starter Thread starter David
  • Start date Start date
D

David

I am loading a datagrid from a dataeset,
this.dataGrid.SetDataBinding(ds_hold,"table");, and I need to get the
GridColumnStyles for the default datasource so that I can format one
of the
fields. I defined a DataGridTableStyle to load to add to the grid,
but I
can not see how to copy the dataset's GridColumnStyles to the
DataGridTableStyle before I add it to the datagrid. The MS help is
very
vague on this point.

Also, how does one match up the col. types with the col. names, so
that one
can find the col. to format when it may change in order?
 
Hi David,
but I can not see how to copy the dataset's GridColumnStyles to the
DataGridTableStyle before I add it to the datagrid.

These cannot copied directly as they are very different beasts. In fact, the
only field you need from the DataTable's DataColumns is the Name field.
Also, how does one match up the col. types with the col. names, so
that one can find the col. to format when it may change in order?

The DataGridColumnStyle's MappingName property should be assigned the
corresponding DataColumn's Name property value. That's how the matching is
established.
 
Back
Top