|
I am using Visual Studio Express (c#).
I have a simple form with a DataGridView and a bindingNavigator.
All I want to do is when the user clicks the 'delete' button on the navigator, I want to show an 'Are you sure?' message to allow them to cancel the operation.
The seemingly obvious thing to do is to put some code is in the RowDeleting event for the data table like this:
void Table_RowDeleting(object sender, DataRowChangeEventArgs e) { DialogResult res = MessageBox.Show("Are you sure ?", "Warning", MessageBoxButtons.YesNo); if (res == DialogResult.No) e.Action = DataRowAction.Nothing; }
The problem is that e.Action is readonly so I cannot change it. I can't do e.Row.RejectChanges() either because nothing has changed yet.
The bindingNavigator doesn't have any events either such (e.g. a DeletingItem() event that allows me to abandon the edit before the table gets called.
The only sort of solution I have found is to ask the user in the RowDeleted event and call RejectChanges if necessary. But this looks ugly as the user can see on the datagrid behind the 'are you sure?' box that the row has already disappeared.
Is it really that hard, are am I missing something simple?
Any help would be appreciated.
Regards
|