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

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)