How Visual C# Helps You Code—Setting Tab Orders


Jump to: navigation, search
CSharp-Online.NET:Articles
Visual Studio Articles

How Visual CSharp Helps You Code

© 2006 Peter Wright

Setting Tab Orders

Imagine that you had a form like the one in Figure 7-10.


Image:VCSExpressfig-7-10.jpg
Figure 7-10. All forms require some attention to navigation order, especially when they get a little complex like this one.


That’s a pretty complex form. Now imagine that you came across this form in an application you had installed—perhaps it’s part of a registration dialog for an application you adore. Out of the box there are a few assumptions you and any other user would make about how this form works. Perhaps the biggest assumptions are that when you start editing the form, the cursor will start in the topmost text box, and that pressing Tab will take you down through all the text boxes in the form until you reach the bottom one. You would quickly lose faith in the program if pressing the Tab key moved you all over the form in a seemingly random order.

When you design your user interfaces, C# Express provides you with help in specifying the tab order of the controls on forms.

Take a look at the View menu (see Figure 7-11).


Image:VCSExpressfig-7-11.jpg
Figure 7-11. Visual C# 2005 Express’s View menu


If you select the Tab Order item from the View menu, the form you are working on changes to Tab Order mode, just like mine in Figure 7-12.


Image:VCSExpressfig-7-12.jpg
Figure 7-12. Selecting Tab Order from the View menu shows you the current tab order of the controls on the form.


In Tab Order mode, all you need to do to set up the tab order of the controls on the form is to simply click on them one by one. Don’t forget to click on the Label controls as well, because you can set a hot key for a label by using & in the label’s Text property (for example, &Next to display Next); when you select a label by pressing its hot key, focus moves to the next control in sequence.

When you are finished clicking away, just press the Esc key on the keyboard to leave Tab Order mode. What could be easier?


Previous_Page_.gif Next_Page_.gif


Personal tools