Home Forums WinForms controls Xceed Grid for WinForms Inserting data programatically in master-detail grid Reply To: Inserting data programatically in master-detail grid

User (Old forums)
Member
Post count: 23064

Hi Creat,

if I run your code, an error is thrown: ‘parentrow is not a member of InsertionRow2’.

Meanwhile, I got a hint from the technical support of XCeed. They told me:

“The row is not inserted because the insertion row was put in a invalid state since the grid cought an exception when you are trying to set the InsertionRow2.Cells(“Quantity”).Value = ‘xy’.

An exception is thrown and caught by the grid because you cannet set the value of a row which is part of a template… in your case, InsertionRow2 is part of the gridControl’s DetailGridTemplates and is used to create all of your detailGrid’s insertionRows.

Instead, you will want to cast the sender of your EditBegun event handler into an insertionRow (or a cellRow), ie:

CType(sender, Xceed.Grid.CellRow).Cells(“Quantity”).Value = 5

This will nonetheless be considered a bug in our code since this throw should not put the insertionRow in an invalid state and should still be able to insert data.”

Unfortunately, the recommended code line does not work neither, at least, if I simply enter this code line into my Edit-Begun-event.

How would you proceed in this case? (For the simplicities sake you can use the XCeed-Sample “Master-Detail-Grid”, adding an insertion row underneath the detail grid there).

Thanks for your efforts!
Wolfgang

Imported from legacy forums. Posted by wolfgang (had 723 views)