Home Forums WinForms controls Xceed Grid for WinForms Adding new rows into a Master/Detail GridControl

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

    Hey,

      I am running the Master/Detail sample by using the Xceed GridControl, and I am wondering that whether it is possible to add new child rows into a parent, or add another top item, and then add child rows into the new top item, is that doable? Currently, the sample only allows editting each data cell on each row, but cannnot add new rows on any level. Therefore, if I can want to add new child rows or parent rows, what properties or what settings I need to set. By the way, I am using the Master/detail sample of Xceed Grid .NET from the http://xceed.com/Grid_WinForms_Demo.html.

      Thanks for your help in advance.

    Imported from legacy forums. Posted by Software Engineer (had 2001 views)

    User (Old forums)
    Member
    Post count: 23064

    You need to use an event (like a button click) to add a new row to the mater grid.  Then use the InitializingDetailGrid event to add new rows to the corresponding detail grid.

    e.g.:

        private void button1_Click( object sender, EventArgs e )
        {
          gridControl1.InitializingDetailGrid += new InitializingDetailGridEventHandler( gridControl1_InitializingDetailGrid );

          Xceed.Grid.DataRow masterRow = gridControl1.DataRows.AddNew();
          masterRow.Cells[ 0 ].Value = someValue;
          masterRow.EndEdit();
        }

        void gridControl1_InitializingDetailGrid( object sender, InitializingDetailGridEventArgs e )
        {
          gridControl1.InitializingDetailGrid -= new InitializingDetailGridEventHandler( gridControl1_InitializingDetailGrid );

          Xceed.Grid.DataRow detailRow = e.Grid.DataRows.AddNew();
          detailRow.Cells[ 0 ].Value = someOtherValue;
          detailRow.Cells[ 1 ].Value = e.Grid.ParentDataRow.Cells[ 0 ].Value;
          detailRow.EndEdit();     
        }
     

     

    Imported from legacy forums. Posted by André (had 1882 views)

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