Keys [modified]
-
Hy, I have the following code put in the protected override OnKeyDown to a RichTextBox: switch (e.KeyCode) { case Keys.Tab: case Keys.Enter: { autocomplete(_defaultColor); e.Handled = true; break; } } and the autocomplete method: private void autocomplete(Color defaultColor) { for (int i = 0; i < 1; i++) { SendKeys.SendWait("{BACKSPACE}"); } SendKeys.SendWait("public"); } 1.Run the application and press "p" then press ENTER. 2.Run the application and press "p" then press TAB. In both cases the effect is different but is the same code for both cases. Can somebody give me an explication? -- modified at 8:58 Tuesday 9th October, 2007
-
Hy, I have the following code put in the protected override OnKeyDown to a RichTextBox: switch (e.KeyCode) { case Keys.Tab: case Keys.Enter: { autocomplete(_defaultColor); e.Handled = true; break; } } and the autocomplete method: private void autocomplete(Color defaultColor) { for (int i = 0; i < 1; i++) { SendKeys.SendWait("{BACKSPACE}"); } SendKeys.SendWait("public"); } 1.Run the application and press "p" then press ENTER. 2.Run the application and press "p" then press TAB. In both cases the effect is different but is the same code for both cases. Can somebody give me an explication? -- modified at 8:58 Tuesday 9th October, 2007
Hi, unless you set KeyEventArgs.SuppressKeyPress true, there will be a KeyPress event, which will act differently for ENTER and TAB. :)
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
-
Hi, unless you set KeyEventArgs.SuppressKeyPress true, there will be a KeyPress event, which will act differently for ENTER and TAB. :)
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
-
Hello Luc,
Luc Pattyn wrote:
set KeyEventArgs.SuppressKeyPress true
very interesting! Do you also know a .Net 1.1 solution for that problem?
All the best, Martin
Hi Martin, sorry I don't know a replacement for KeyEventArgs.SuppressKeyPress other than adding specific code in one or both event handlers. I stopped using .NET 1.x completely. Greetings,
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
-
Hi Martin, sorry I don't know a replacement for KeyEventArgs.SuppressKeyPress other than adding specific code in one or both event handlers. I stopped using .NET 1.x completely. Greetings,
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
-
Hello Luc, But isn't there allways the problem, that the "Tab" leeds to loosing the Focus of the Control?
Luc Pattyn wrote:
I stopped using .NET 1.x completely.
Oh no! The last one (apart from me) left the ship! :)
All the best, Martin
Martin# wrote:
But isn't there allways the problem, that the "Tab" leeds to loosing the Focus of the Control?
There was and is a solution to these by using one of Control.IsInputChar and Control.ProcessCmdKey :)
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
-
Martin# wrote:
But isn't there allways the problem, that the "Tab" leeds to loosing the Focus of the Control?
There was and is a solution to these by using one of Control.IsInputChar and Control.ProcessCmdKey :)
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google