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

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

    I have problems with entering programatically data into an insertion row when it is part of a master detail grid environment. In the reverse case, i.e. in a simple master grid, there I simply subscribe to the EditBegun event and realize the insertion with a ‘InsertionRow1.cell(0).value = xy’ – command.

    But in a master detail grid setting the detail grid simply does not accept the data, nor does the coresponding EditBegun event throw an error message. And if I want to insert the data subscribing the ending-edit event, an error message is thrown: ‘An attempt was made to insert data into an insertion row, whose parent insertion row does not have an underlying data row.’ (This error message does not appear in the simple master grid case, too.)

    Does anybody know how to deal with this case?

    Wolfgang Sohst / Berlin, Germany

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

    User (Old forums)
    Member
    Post count: 23064

    try this:

    Dim row As XceedGrid.CellRow = sender.parentrow
    Dim gc2 As Xceed.Grid.DataRow = GridControl2.DataRows.AddNew()

    gc2.Cells(“Col Name”).Value = txtTest.text
    gc2.EndEdit()

    Imported from legacy forums. Posted by Creat (had 687 views)

    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)

    User (Old forums)
    Member
    Post count: 23064

    Hi Creat,

    sorry: the code line recommended by the XCeed Software Technical Support DOES work. Everything allright.

    Thanks again.
    Wolfgang

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

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