Reputation: 4341
As far as I can tell, the best way to do this is do it in the DataTable.RowChanging event. But what if I want to cancel the action? There is no EventArgs.Cancel option...
Upvotes: 1
Views: 482
Reputation: 4341
In the case of the DataGridView
, if you throw an exception in DataTable.RowChanging
, you can handle it in DataGridView.OnError
. Setting EventArgs.Cancel
to true
preserves data entry.
Upvotes: 0
Reputation: 35196
From the DataTable.RowChanging event handler, you can throw an exception to cancel the change. The exception will be thrown to the piece of code making the change where you can handle it appropriately.
Upvotes: 1