BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
I have a situation in my production code where I need to "manually" invoke the row validation. In my case I'm not using the SfDataGrid add new row functionality, instead the user pressing a button to add a row.
Closing the view invokes the save (back to database) functionality, but I don't want to save any records if the validation fails. If the user adds a row and edits it and closes the view the validation is not invoked.
You can achieve the same result by running the following Syncfusion sample
wire the RowValidating event for pasted content in datagrid | WPF - SfDataGrid (syncfusion.com)
Start the application
Edit the employee name and change it to Null.
Close the application and the private void DataGrid_RowValidating(object sender, RowValidatingEventArgs e) method does not get called. It is only called when you select another row in the table.
How do I invoke the validation, if the focus changes from a row in the grid to any control outside of the grid
The row validating event occurs when the edited cells try to commit the row data or lose focus. But as per your scenario, you want to trigger the row validating event when the window gets closed while the cell is in editing. However, we are still analyzing your requirement to "trigger the row-validating event when the window is closing" and will update you with further details on December 9, 2022.
We are still analyzing your requirement to "trigger the row-validating event when the window is closing" and will update you with further details on December 13, 2022.
You can trigger the row validating event when the window is closing by calling the method CheckValidationAndEndEdit() in Window.Closing event, and here you can handle the window closing CheckValidationAndEndEdit() method's returned value. Refer to the below screenshots and a sample to get more information.