006 – Setting tab order for components at the form

Setting tab order for components on the form



Suppose there is form of our application, which is shown in figure 1.


Fig. 1. Main form of application

The form contains five components (controls), which can get input focus:

  • Button1
  • Button2
  • Edit1
  • Edit2
  • Edit3

We need to set the movement between this components with the help of tab keys so, that when the application is running, the order of changing between components to each other will be as follows:

  1. Edit1
  2. Edit2
  3. Edit3
  4. Button1
  5. Button2


1. Calling the command “Tab Order…

Press the right mouse button in area of main form.

As a result the context menu (fig. 2), in which we need select command “Tab Order…” will be opened.


Fig. 2. Calling of command “Tab Order…” from the context menu


2. Setting up the order of alternating of the components

Window “Edit Tab Order” (fig. 3) will be opened.

In the right side of opened window with the help of arrow keys set the order as shown in figure. Your choice confirm by pressing on button “Ok“.


Fig. 3. Window of editing of alternation the components


3. Programming the event of form activation

In order to when application is running, the input focus primarily will set to Edit1, we need to type the corresponding program code to event of form activation.

Listing the event’s of form activation:

procedure TForm1.FormActivate(Sender: TObject);

If you need to get input focus

If you need to get input focus on application startup received component Button1 then the activation code will have next view:

procedure TForm1.FormActivate(Sender: TObject);


In this topic considered:

1. Setting up of sequence of getting the input focus by components of the form when the key “Tab” (Shift+Tab) is pressed. It should be noted that not all Delphi component can receive the input focus (for example component TLabel).

2. Setting up with the help of programming of the input focus for needed components (controls) by calling the method “SetFocus“.