只读文本框不允许菜单项快捷方式

发布于 2024-12-06 17:04:14 字数 200 浏览 7 评论 0原文

我有一个只读的文本框。我还有一个工具条菜单项,其快捷方式为 Ctrl + R。当焦点位于文本框中时,工具条菜单项快捷方式不再起作用。

我可以与按键按下事件相交并检查该键是否为 Ctrl + R,但由于我使用的是通用文本框控件,因此这需要引发事件或传递委托来调用通用控件的给定特定键。

如果焦点位于只读控件上,是否有人有过触发工具提示菜单项快捷方式的经验?

I have a text box which is read only. I also have a tool strip menu item which has a short cut of Ctrl + R. When the focus is in the textbox the toolstrip menuitem shortcut no longer works.

I can intersect the key down event and check if the key was Ctrl + R, but since I am using a generic text box control, this would take raising an event or passing a delegate to call given specific keys to my generic control.

Does anyone have any experience getting a toolstip menuitem's shortcut to fire if the focus is on a read only control?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

俯瞰星空 2024-12-13 17:04:14
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) 
{
  if (keyData == (Keys.Control | Keys.R)) 
  {
      MessageBox.Show("Handle with care! :)");
  }

  return base.ProcessCmdKey(ref msg, keyData);
}

将该逻辑放在包含只读控件的窗体上。

protected override bool ProcessCmdKey(ref Message msg, Keys keyData) 
{
  if (keyData == (Keys.Control | Keys.R)) 
  {
      MessageBox.Show("Handle with care! :)");
  }

  return base.ProcessCmdKey(ref msg, keyData);
}

Put that logic on the form that contains the read-only control.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文