Charlotte Foust
cfoust at infostatsystems.com
Mon Oct 6 10:07:55 CDT 2008
Aside from the differences in language (we use VB.Net) and the specific events (we use 3rd party grids) that's pretty much what we do and what I would do on a datagridview where I allowed deletes like that. Charlotte Foust -----Original Message----- From: dba-vb-bounces at databaseadvisors.com [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Gustav Brock Sent: Monday, October 06, 2008 1:19 AM To: dba-vb at databaseadvisors.com Subject: [dba-VB] DataGridView BindingNavigator: Confirm delete row 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 _______________________________________________ dba-VB mailing list dba-VB at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-vb http://www.databaseadvisors.com