如何禁用 DataGridView 的键盘快捷键? [英] How do you disable a DataGridView's keyboard shorcuts?

查看:74
本文介绍了如何禁用 DataGridView 的键盘快捷键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚注意到 DataGridViews 有一个默认的快捷方式,所以每当你按下 Ctrl + HDataGridView 的编辑控件退格,可以删除单元格内的整个选择.

I've just noticed that DataGridViews have a default shortcut so that whenever you press Ctrl + H, the DataGridView's editing control backspaces, and can delete your entire selection within the cell.

这会变得很烦人,因为每当按下 Ctrl + H 时我都想打开一个替换框.有什么办法可以停止退格,同时还能用它打开替换框?

This can get quite annoying since I want to open a Replace box whenever Ctrl + H is pressed. Is there any way to stop the backspacing while still being able to use it to open the replace box?

我正在运行 C# 2.0,但如果较新的 C# 有解决方案,我可以将我的应用程序更新到 3.5.

I'm running C# 2.0, but I could update my application to 3.5 if the newer C# has a solution.

推荐答案

这会进入您的表单代码:

This goes into 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
}

这篇关于如何禁用 DataGridView 的键盘快捷键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆