Gustav Brock
Gustav at cactus.dk
Mon Oct 6 03:18:53 CDT 2008
Hi all The DataGridView has an event, UserDeletingRow, with the option to cancel the delete caused by pressing the Delete button of the keyboard. But if the user clicks the Delete toolstripbutton of the bindingnavigator, no such event exists. Why? So what do you do to pop a messagebox asking the user to confirm to delete the row? The only solid method I've found is to connect or disconnect the Delete button from the delete action of the bindingnavigator like this: private void bindingNavigator1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { if (e.ClickedItem.Equals (bindingNavigatorDeleteItem )) { DataGridViewRow deletedRow = dataGridView1.CurrentRow; int indexColumnDessinNumber = 1; string dessinNumber = deletedRow.Cells[indexColumnDessinNumber].Value.ToString(); <snipped mb code> DialogResult result = MessageBox.Show(owner, prompt, caption, buttons, icon, defaultButton); bool cancel = !result.Equals(DialogResult.OK); if (cancel) { bindingNavigator1.DeleteItem = null; } else { bindingNavigator1.DeleteItem = bindingNavigatorDeleteItem; } } } This works very well, but I wonder if a more clever solution exists? /gustav