开发者

Readonly text box not allowing menuitem shortcut

开发者 https://www.devze.com 2023-04-09 01:24 出处:网络
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 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 co开发者_如何学Pythonntrol, 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消