views:

380

answers:

1

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

+2  A: 

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

Rob Fonseca-Ensor
Thanks for your help Rob!!
Ashish Ashu