Restrict Delete Key

Posted by Santosh4u under VB.NET on 10/1/2010 | Points: 10 | Views : 2244 | Status : [Member] | Replies : 1
Hi All

can any body plz tell me how to restrict to delete the record in "Delete" key press.
i m working in windows application ,i have a datagridview and i have added some rows ,when ever i am clicking the "Delete" key it shouldn't delete any rows.


it's very urgent.........

Regards
Santosh




Responses

Posted by: Prasham on: 10/1/2010 [Member] Starter | Points: 25

Up
0
Down
Hello,

I haven't tried but one suggestion - Whenever user hits the Delete key for a row in datagridview control, UserDeletingRow event fires.So by using Cancel property you can cancel the deleting of the row.

Sample code :

private void dataGridView1_UserDeletingRow(
object sender,
System.Windows.Forms.GridViewRowCancelEventArgs e) {
e.Cancel = true;
}

Hope this will help you.

Thanks
Prasham

Thanks and Best Regards
Prasham

Santosh4u, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response