Home Forums WinForms controls Xceed Grid for WinForms Add rows to Detail Grid Reply To: Add rows to Detail Grid

User (Old forums)
Member
Post count: 23064

Thanks to the good folks at Xceed support, I have some working code regarding this issue.

Here is what I end up with.
If you have selected a row in the master grid,
foreach (Xceed.Grid.DataRow dataRow in masterGrid.SelectedRows)
{
Xceed.Grid.DataRow newRow = dataRow.DetailGrids[0].DataRows.AddNew();
// be sure to assign any required data
newRow.Cells[“name of the cell”].Value = value;
newRow.EndEdit();
}

If the selected row is in the detail grid,
foreach (Xceed.Grid.DataRow dataRow in masterGrid.SelectedRows)
{
Xceed.Grid.DataRow newRow = dataRow.ParentGrid.DataRows.AddNew();
// be sure to assign any required data
newRow.Cells[“name of the cell”].Value = value;
newRow.EndEdit();
}

It is imperitave that any required data be entered into the appropiate cell values or the row will not be created. There may be no errors to tell you what is going on.

I hope this helps out. Please let me know if you find other code examples that works better, of if this code does not get you going.

Thanks

KenG

Imported from legacy forums. Posted by KenG (had 791 views)