Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trap delete row ( from keyboard ) in datagridview?

Background I have a custom collection that is binded to the datagridview

this.datagridview.DataSource = mycollection

I have a delete button on the user interface . User can click on the delete button to delete the selected DX Directory.

Some entried cannot be deleted so I Enable and Disable "delete button".

It works fine in case user user deletes entry by clicking the delete butoon.

The problem is :

When user pressed the "delete" button from the "keyboard"

How can trap key board "Delete" button.. When I press delete button from the keyboard:

--it deletes a selected row from the datagrid view.. --When user click save .. it also saves it into Xml as well..

To correct this I have handled _RowRemoved event of datagrid view.. but still no help

Please Help

like image 600
Ashish Ashu Avatar asked Nov 02 '09 08:11

Ashish Ashu


1 Answers

Attach to the UserDeletingRow event, and cancel the deletion (when required) by setting e.Cancelled = true

like image 66
Rob Fonseca-Ensor Avatar answered Oct 13 '22 00:10

Rob Fonseca-Ensor