Handling Shift Del in C#

Posted by  Takeshi Okada
 2427  View(s)
Rate this:

Hi Expert!

I am having a DataGridView in a winform with delete handled which authenticates and deletes those rows. However, pressing Shift+Del deletes the rows from

UI. I have tried setting a boolean IsShiftPressed by handling keydown event but that looks ugly. Surely there should be a better way to do it.

Please reply ASAP! Thanks

  1. Re: Handling Shift Del in C#

    Hi Takeshi!

    Try in KeyUp Event

    if (e.KeyCode == Keys.Del && e.Shift) 

       if (dataGridView1.SelectedRows.Count > 0) 
            //Do Stuff 
       e.Handled = true;

      Modified On Mar-29-2018 10:51:01 PM