Home Forums WinForms controls Xceed Grid for WinForms Saving each row + error handling

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

    I need bit of help.

     I bind System.Data.DataTable to grid and I want to save the row when I leave the row edit. (Always just one row that I am saving in the grid each time). When I save I might get error from the database (due to contrains og trigger or what ever) and if that happens I would like the edit to stay in the row I was editing. 

     I have tryed this few diffrent ways but never get it right. Any ideas?

      best regards

    Einar

    Imported from legacy forums. Posted by Einar (had 565 views)

    User (Old forums)
    Member
    Post count: 23064

    You can use the LeavingEdit event to validate the data, set the Cancel property to true, which will trigger the ValidationError event, and set the CancelEdit property to false.

    e.g. :

    private void Form1_Load( object sender, EventArgs e )

    {

        insertionRow1.Cells[

    “City” ].LeavingEdit += new LeavingEditEventHandler( Form1_LeavingEdit );

        insertionRow1.Cells[ “City” ].ValidationError += new CellValidationErrorEventHandler( Form1_ValidationError );

    }

    void Form1_LeavingEdit( object sender, LeavingEditEventArgs e )

    {

        if( ( string )e.NewValue != “Paris” )

            e.Cancel =

    true;

    }

    void Form1_ValidationError( object sender, CellValidationErrorEventArgs e )

    {

        e.CancelEdit =

    false;

    }

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

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