Home Forums WinForms controls Xceed Grid for WinForms Detail Grid in Unbound Mode Reply To: Detail Grid in Unbound Mode

User (Old forums)
Member
Post count: 23064

The code that I am providing has details for all the rows. I hope this will help you.

Just add these three methods to the form where your gridcontrol is on.

DataSet ds;
private DataSet CreateDataSet()
{
ds = new DataSet(“DataSetName”);

DataTable dt = new DataTable(“Table1”);
dt.Columns.Add(new DataColumn(“Relation”,typeof(string)));
dt.Columns.Add(new DataColumn(“Column1”));
dt.Columns.Add(new DataColumn(“Column2”,typeof(string)));
dt.Columns.Add(new DataColumn(“Column3”,typeof(string)));

DataTable dt1 = new DataTable(“Table2”);
dt1.Columns.Add(new DataColumn(“Relation”,typeof(string)));
dt1.Columns.Add(new DataColumn(“Table2Column1”,typeof(string)));
dt1.Columns.Add(new DataColumn(“Table2Column2”,typeof(string)));
dt1.Columns.Add(new DataColumn(“Table2Column3”,typeof(string)));

ds.Tables.Add(dt);
ds.Tables.Add(dt1);

ds.Relations.Add(“MyRelation”,dt.Columns[“Relation”],dt1.Columns[“Relation”]);
return ds;
}
private void LoadDataSet()
{
try
{
for(int i=0;i<=3;i++)
{
ds.Tables[“Table1″].Rows.Add(new object[] {i,””,””,””});
ds.Tables[“Table2”].Rows.Add(new object[] {i,”MyText “+i,”MoreText”,”SomeMoreText”});
}
}
catch (Exception e)
{
MessageBox.Show(e.Message.ToString());
}
}
private void XceedDataSource()
{
gridControl1.DataSource=ds;
gridControl1.DataMember=”Table1″;
gridControl1.SingleClickEdit=true;

DetailGrid detail = new DetailGrid();
DetailGrid detail2 = new DetailGrid();

detail.HeaderRows.Add( new ColumnManagerRow() );

detail.DataSource=ds;
detail.DataMember=”Table1.MyRelation”;
gridControl1.DetailGridTemplates.Add(detail);

gridControl1.UpdateDetailGrids();
}

Imported from legacy forums. Posted by EliasD (had 1288 views)