Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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!

  • 10 years later...
Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...