J
John Sun
Hi, Dear gurus,
I want to bind my collection to a datagrid. The field names in my object
show up in a weird order, and I just wonder how I could reorder those
columns .
I find some code like the following , but I don't want to do it that way
because it won't work if I have large number of fields.
[
DataGridTableStyle myGridStyle = new DataGridTableStyle();
myGridStyle.MappingName = "GridTableMappingName";
DataGridTextBoxColumn nameColumnStyle = new DataGridTextBoxColumn();
nameColumnStyle.MappingName = "GridColumnMappingName";
nameColumnStyle.HeaderText= "GridColumnMappingName";
myGridStyle.GridColumnStyles.Add(nameColumnStyle);
myDataGrid.TableStyles.Add(myGridStyle);
]
I believe there must be some better way to do that(using reflection) .
Anybody gives me some hint on that. A link to a example is highly
appreciated.
Thanks,
J.W.
I want to bind my collection to a datagrid. The field names in my object
show up in a weird order, and I just wonder how I could reorder those
columns .
I find some code like the following , but I don't want to do it that way
because it won't work if I have large number of fields.
[
DataGridTableStyle myGridStyle = new DataGridTableStyle();
myGridStyle.MappingName = "GridTableMappingName";
DataGridTextBoxColumn nameColumnStyle = new DataGridTextBoxColumn();
nameColumnStyle.MappingName = "GridColumnMappingName";
nameColumnStyle.HeaderText= "GridColumnMappingName";
myGridStyle.GridColumnStyles.Add(nameColumnStyle);
myDataGrid.TableStyles.Add(myGridStyle);
]
I believe there must be some better way to do that(using reflection) .
Anybody gives me some hint on that. A link to a example is highly
appreciated.
Thanks,
J.W.