views:

154

answers:

1
+2  Q: 

RichTextBox CtrlI

I have a RichTextBox in .NET WinForms. I have been hooking up hot keys with KeyUp. Everything is working fine, except for CtrlI. By the time my handler gets its turn, the selection has been replaced with a '\t'. I turned off ShortcutsEnabled, but it didn't make any difference. Any ideas?

+1  A: 

Do it like this:

using System;
using System.Windows.Forms;

public class MyRtb : RichTextBox {
  protected override bool ProcessCmdKey(ref Message m, Keys keyData) {
    if (keyData == (Keys.I | Keys.Control)) {
      // Do your stuff
      return true;
    }
    return base.ProcessCmdKey(ref m, keyData);
  }
}
Hans Passant
Thanks, that did the trick!
Jake Pearson