Cursor Keys

  • Thread starter Thread starter Xarky
  • Start date Start date
X

Xarky

Hi,
I am trying to control the Cursor Keys(Left, Right, Up, Down) in a
Windows Form Application from the KeyPress Event.

Can someone give me some help how do I identify which key was pressed.


Thanks in Advance
 
Hi

I found out Keys.Up, Keys.Left...etc

From the KeyPress EventHandler, I am using e.KeyChar

When comparing (e.KeyChar == Key.Left), a compile time error is given.

Operator '==' cannot be applied to operands of type 'char' and
'System.Windows.Forms.Keys'

How should I do it?

Thanks for your help
 
Hi,

I am doing as follows, in the event handler:

Keys key = (Keys)e.KeyChar;
if (key == Keys.Left)
MessageBox.Show("LEFT");

No messagebox is being given. I set a breakpoint on those lines, and
when I press the errors nothing is happening, but when I press any other
key(Example - a), I am entering in visual studio to debug.

It seems that the arrows keys are not being handled?

Can some further help be given.
Thanks in Advance
 
Hi,
I used the KeyDown Event handler, and it solved my problems


Thanks for your help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top