Setting tab order from one tab control form to the next

G

Guest

I have created a form that contains 4 tab control pages. I am trying to set
the tab order to go from the last in one page to the first in the next. I'm
guessing that I need to set the last control on one page through the 'OnExit'
to go to the first in the next. Can anyone help with the formula I need to
that. Thanks
 
R

Rick Brandt

Anna said:
I have created a form that contains 4 tab control pages. I am trying
to set the tab order to go from the last in one page to the first in
the next. I'm guessing that I need to set the last control on one
page through the 'OnExit' to go to the first in the next. Can anyone
help with the formula I need to that. Thanks

That is one way, but I prefer to use another stategy. The problem with using
the Exit or LostFocus of the last control on each page is it assumes that the
first control on the next page is ALWAYS where the user wants to go. If they
hit <shift-tab> to go backwards or click on a control with the mouse the event
will still fire and jump them to another tab page when that is not what they
wanted. Do the following instead...

Create a tiny TextBox with no label. It needs to be visible (per the Visible
property) so it can receive focus, but you can make the dimensions so small that
it cannot be seen by the user.

Make this TextBox last in the TabOrder on your first TabPage and in its GotFocus
event add a line of code to change focus to the desired control on the second
TabPage...

Me!ControlName.SetFocus

Now when the user leaves your last "real" control on the first TabPage by using
the <Tab> or <Enter> key they will be taken to the first control on the next
TabPage, but if they use <Shift-Tab> or the Mouse then nothing undesired
happens. Repeat this for all other pages.
 

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