how to CATCH arrow key in C#

kante

Newcomer
Joined
Jan 16, 2003
Messages
13
i use

this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress);

and then

private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{ MessageBox.Show("" + e.KeyChar);}

to catch the every key press in my form....


but why it doesn't work with arrow keys?
how can i arrange it to catch all keyboard keys?

thank you!
 
you must derive a new class that is based on the class of the control that you want, and you override the ProcessCmdKey().

Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
'handle your keys here
End Function

Source Code..VB.Net Arraow Keys
 
Back
Top