Home Forums WinForms controls Xceed Grid for WinForms Insertion row save dilemma

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

    I want to have a SaveChanges routine called when the user clicks either a Close button or the form’s close (X in top right corner). The following code works for rows that are being edited when it is called, but if the user is in the Insertion Row, it generates an error 13 “Cannot cast insertion row to data row”.

    Dim dr As Xceed.Grid.DataRow

    dr = GridControl1.CurrentRow
    dr.EndEdit()
    da.Update(ds)

    How do I test for the insertion row, and what code will then commit that to a data row?

    Imported from legacy forums. Posted by Phil (had 2815 views)

    User (Old forums)
    Member
    Post count: 23064

    never mind, I figured it out – setting the insertion row in code instead of the designer

    Imported from legacy forums. Posted by Phil (had 297 views)

    User (Old forums)
    Member
    Post count: 23064

    After further review, there is still a way this can be a problem. If the insertion row has just been added, but another datarow has not been selected, then the currentrow is an insertionrow and

    dr = GridControl1.CurrentRow

    generates an error 13.

    How can I test in code whether the currentrow is an insertionrow?

    Routine is:

    Dim dr As Xceed.Grid.DataRow

    If ir.IsBeingEdited Then
    ir.EndEdit()
    Else
    dr = GridControl1.CurrentRow
    dr.EndEdit()
    End If
    da.Update(dsDist, “Distributors”)

    Imported from legacy forums. Posted by Phil (had 439 views)

    User (Old forums)
    Member
    Post count: 23064

    You can use the following to verify the type of the CurrentRow is an InsertionRow :

    If TypeOf GridControl1.CurrentRow Is InsertionRow Then

    End If

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

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