How to setup dynamic GridColumnStyles from a datasource?

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?
 
D

Dmitriy Lapshin [C# / .NET MVP]

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.
 

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