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)
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?
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