If you want to use many children, for example:
class MyClass { public int Id; public MyOtherClass OtherClass; } class MyOtherClass { public string Name; public int Number; }
What about:
1st solution Set a value for each cell in an event (for example, something else is better), manually, after setting the data source, for example:
private void dgv_CellFormatting( object sender, DataGridViewCellFormattingEventArgs e ) { MyClass data = dgv.Rows[ e.RowIndex ].DataBoundItem as MyClass; dgv.Rows[ e.RowIndex ].Cells[ "colName" ].Value = data.OtherClass.Name; dgv.Rows[ e.RowIndex ].Cells[ "colNumber" ].Value = data.OtherClass.Number; }
2nd solution How about creating the proper DataTable from the data and then just bind it?
I would be grateful for any opinion; -)
Ryfcia
source share