How to disable shorcuts for DataGridView keyboard?

I just noticed that it DataGridViewhas a default shortcut, so whenever you click Ctrl+ H, the inverse of the edit control area DataGridViewcan delete all your selection inside the cell.

This can be annoying because I want to open the Replace field whenever Ctrl+ is pressed H. Is there a way to stop the backward movement while still being able to use it to open the replacement field?

I am running C # 2.0, but I can upgrade my application to 3.5 if the new C # has a solution.

+5
source share
2 answers

This is included in your form code:

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{     
  if (keyData == (Keys.Control | Keys.H))
  {
    //ShowReplaceDialog() or whatever it is you want to do here.
    return true; //we handled the key
  }

  return base.ProcessCmdKey(ref msg, keyData); //we didn't handle it
}
+5
source

void m_dgv_KeyDown(object sender, KeyEventArgs e)
    {
               if (e.KeyCode == (Keys.Control | Keys.H))
                {
                  e.Handled = true;
                }
   }
0
source

All Articles