开发者

execute action on hotkey without capture it

I want to execute action in my C# application when user clicks e.g. Ctrl+C combination. I've found a spcific code, but i want - when user hits ctrl+c - the selected text will be copied & will be executed action in my开发者_JAVA百科 app instead just execute action.


Use a KeyDown event:

private void m_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
   if (e.Control && e.KeyCode == Keys.C) 
   {
      //Grab selected text
      Clipboard.SetText(richTextBox1.SelectedText);
      string s = Clipboard.GetText();
      //Execute some action with the string
   }
}

You will also need to register the key event handler from the designer.cs for whetever you like to use it. Example:

this.richTextBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.m_KeyDown);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜