Home Forums WinForms controls Xceed Grid for WinForms Detail Grid in Unbound Mode

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #13499 |

    Hi.
    I’d like to have a grid like this:

    Col1 – Col2 – Col3
    ———————–
    A1 – A2 – A3
    B1 – B2 – B3
    +C1 – C2 – C3
    C11 – C21 – C31
    C12 – C22 – C32
    C13 – C23 – C33
    D1 – D2 – D3

    My grid is unbound, so i add rows and value manually.
    Some rows must have a plus “+” in the first column, and when the user click on “+” i have to show other rows filled manually.

    How can i do this?

    Thanks

    Imported from legacy forums. Posted by Gian Luigi (had 665 views)

    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)

    User (Old forums)
    Member
    Post count: 23064

    I want to do the same sort of thing but do not want to use a data table or dataset. Is there a way to add rows to the detailgrid using AddNew()?

    Greg

    Imported from legacy forums. Posted by HHGClark (had 3348 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.