I've created a DataGrid with a TableStyle, I set the datasource of the DataGrid to a DataTable, and it works great. I can see the columns I specified in the TableStyle.
I've loaded another DataTable and linked this new table to the existing table so my datagrid can use the DataRelation object to show these tables in same datagrid.
The problem is, my TableStyle for the Parent is no longer being used. Is it possible to apply a TableStyle in this situation?, If so, how can I go about this?
Here is some code snippets:
I've loaded another DataTable and linked this new table to the existing table so my datagrid can use the DataRelation object to show these tables in same datagrid.
The problem is, my TableStyle for the Parent is no longer being used. Is it possible to apply a TableStyle in this situation?, If so, how can I go about this?
Here is some code snippets:
Code:
private void MakeDataRelation(){
// DataRelation requires two DataColumn (parent and child) and a name.
DataRelation myDataRelation;
DataColumn parentColumn;
DataColumn childColumn;
parentColumn = myDataSet.Tables["ParentTable"].Columns["id"];
childColumn = myDataSet.Tables["ChildTable"].Columns["ParentID"];
myDataRelation = new DataRelation("parent2Child", parentColumn, childColumn);
myDataSet.Tables["ChildTable"].ParentRelations.Add(myDataRelation);
}
private void BindToDataGrid(){
// Instruct the DataGrid to bind to the DataSet, with the
// ParentTable as the topmost DataTable.
dataGrid1.SetDataBinding(myDataSet,"ParentTable");
}