Readonly text box not allowing menuitem shortcut
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.
精彩评论