I am trying to delete rows from datagridview, when the user selects any row and clicks on delete button , it should ask the user whether he wants to delete the rows?
I am able to delete the rows but I am not sure my control doesnot come to method below:
private void dataGridView1_UserDeletingRow(object sender,DataGridViewRowCancelEventArgs e)
{
DialogResult usersChoice =
MessageBox.Show("Are you sure you want to delete the selected signs?\r\n" + dataGridView1.SelectedRows.Count + " signs will be deleted!", "Signs", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
// cancel the delete event
if (usersChoice == DialogResult.Cancel)
e.Cancel = true;
}
I am not sure what show I write in my code so that when user clicks delete button the control comes to the above logic.
Any suggestions?
Thanks.
You can register for this event in the Constructor of your
Form.For example: