User pressing TAB or Enter to advance to next field on a form

  • Thread starter Thread starter eljainc
  • Start date Start date
E

eljainc

Hello,

I have a perplexing situation. I am using Visual Studio 2005 SP1 and
have created a simple form with two or three textboxes on them. They
are not multi-line text boxes. I would like the behavior of them to
advance to the next control when Tab or ENTER is pressed. However I
cannot seem to change the property to do this. Sure I could write a
KeyDown event handler to mimic this, but why invent the wheel? Can
someone shed some insight into this? Is there another property that I
am not seeing? I have tried AcceptsTab and AcceptsReturn, but those do
not seem to have any effect on the tab/enter working.

Thanks
Mike
 
Hello,

I have a perplexing situation. I am using Visual Studio 2005 SP1 and
have created a simple form with two or three textboxes on them. They
are not multi-line text boxes. I would like the behavior of them to
advance to the next control when Tab or ENTER is pressed. However I
cannot seem to change the property to do this. Sure I could write a
KeyDown event handler to mimic this, but why invent the wheel?   Can
someone shed some insight into this? Is there another property that I
am not seeing? I have tried AcceptsTab and AcceptsReturn, but those do
not seem to have any effect on the tab/enter working.

Thanks
Mike

Tab should by by default, take a look at TabIndex property.
For Enter you must use Form.ProcessCmdKey (or KeyDown event)
 
Tab should by by default, take a look at TabIndex property.
For Enter you must use Form.ProcessCmdKey (or KeyDown event)

The TabIndex IIRC controls the order of the controls on the form that
the Tab key will
activate.

I trapped the Enter key on the KeyDown event. I'm still stuck though
as I cannot get it
to move to the next field. What am I missing here?
 
The TabIndex IIRC controls the order of the controls on the form that
the Tab key will
activate.

I trapped the Enter key on the KeyDown event. I'm still stuck though
as I cannot get it
to move to the next field.  What am I missing here?- Hide quoted text -

- Show quoted text -

Hi,

You have two options:
1- Detect which is the control with the next TabIndex and do a
Control.Focus() to it
2- See if you can "change" the key pressed from enter to TAB. You can
set KeyPressEventAgrvs.KeyChar to the correct char
 

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