Use Enter Key or Arrow Key as well as Tab Key

G

Guest

I have a client who wishes to use the Enter Key and/or Arrow Keys, as well as
the Tab Key, to navigate between Fields in a Windows form.

Is this possible using C# in Visual Studio 2000 ?
 
S

ShaneB

Yes, you can use Control.KeyDown (or Control.KeyUp) event to accomplish
this.

ShaneB
 
G

Guest

Look into KeyPreview, OnKeyPress.

KeyPreview instructs the framework to send you the keys pressed on the form.
OnKeyPress will allow you to see what key is pressed. You can then use the
following code to find the next control:

if (ActiveControl != null)
ActiveControl.GetNextControl(ActiveControl, true);

Don't forget to check for shift key. Pass false to the second param in that
case.
 
S

ShaneB

Using the form's KeyPreview will work....but using the KeyPress event will
not. He will need to use the KeyUp or KeyDown event instead.

From the online help:
"The KeyPress event is not raised by noncharacter keys; however, the
noncharacter keys do raise the KeyDown and KeyUp events."

ShaneB
 

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

Top