GridControl建立主从表示例

DataSet ds = new DataSet();
            DataTable dt1 = Common.TestData.StudentTable.Copy();
            dt1.TableName = "dt1";
            DataTable dt2 = Common.TestData.StudentTable.Copy();
            dt2.TableName = "dt2";
            ds.Tables.Add(dt1);
            ds.Tables.Add(dt2);
            DataRelation relation = new DataRelation("Level2", ds.Tables[0].Columns[0], ds.Tables[1].Columns[0]);//这个Level2要与GridView的关系相同
            ds.Relations.Add(relation);
            MainGrid.DataSource = ds.Tables[0];

你可能感兴趣的:(grid)