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

User (Old forums)
Post count: 23064

Sure thing.

One way is to select the row you want to get/set data to in the detail grid.
You would want to get to it my accessing the selected row of the master grid.

//Create a variable to hold any required data before accessing the grid.
string getValue = “”;

// Access the selected row
foreach (Xceed.Grid.DataRow parentRow in myMasterGrid.SelectedRows)
// Then, if you need the value to the selected row, you can set it get it.
row.Cells[“name of desired column”].value = Value;

// or if you want to get the value

getValue = row.Cells[“name of desired column”].Value.ToString();

Another way to get or set values is to rifle through all of the rows, compareing them with a condition statement. Something like:

// Access the master grid first.
foreach (Xceed.Grid.DataRow parentRow in myMasterGrid.DataRows)
// If you have selected a row in the detail grid to look for, or set values on
// Start a new loop to get to the selected row
foreach (Xceed.Grid.DataRow childRow in parentRow.DetailGrids[0].DataRows)
if (childRow.IsSelected)
getValue = childRow.Cells[“name of desired column”].Value.ToString();

// Or to set the value
childRow.Cells[“name of desired column”].Value = value;

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