G
Guest
I tried suppressing up/down arrow in a textbox. By default up/down
moves the cursor in the textbox left/right and I wanted to suppress
this default behavior in order to use the up/down keys for my own
purposes:
text.KeyDown += textBoxKeyDownHandler;
.....
private void textBoxKeyDownHandler(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyCode == Keys.Down && e.KeyCode == Keys.Up)
e.SuppressKeyPress = true;
}
This didn't work. My handler is called, but the up/down keys work in
the textbox as before, they move the cursor left/right. Any tip what
I'm doing wrong?
moves the cursor in the textbox left/right and I wanted to suppress
this default behavior in order to use the up/down keys for my own
purposes:
text.KeyDown += textBoxKeyDownHandler;
.....
private void textBoxKeyDownHandler(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyCode == Keys.Down && e.KeyCode == Keys.Up)
e.SuppressKeyPress = true;
}
This didn't work. My handler is called, but the up/down keys work in
the textbox as before, they move the cursor left/right. Any tip what
I'm doing wrong?