When the input cursor is in the text box, I want to catch the arrow keys, do some processing, and then don't let this event handle the input.
In an KeyPressevent KeyPressEventArgswe can put e.Handled=false;
to deal with. But the Arrows keys do not fire the event KeyPress.
I tried with e.IsInputKey = true;, then int KeyDownEvent, as MS says.
Msdn Control.PreviewKeyDown Event
But it e.Handled=false;doesn't seem to work either.
Here is my current code
private void textBox1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
if (e.KeyCode == Keys.Right || e.KeyCode == Keys.Left)
e.IsInputKey = true;
}
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Right || e.KeyCode == Keys.Left)
{
e.Handled = false;
}
}

I want to change the default keystroke behavior in a TextBox that moves the cursor. I do not want the input cursor between "r" and "l" (see above) to be able to move.
Any suggestion?