Ide Indy Delphi

Title: Auto TabOrder - Programmatically Fix the TabOrder property in your Delphi applications
Tip submitted by Jens Borrisholt
The TabOrder property exposed by all TWinControl descendant controls (such as TButton, TEdit, TComboBox, etc.) indicates the position of the control in its parent's tab order.
Tab order is the order in which child controls are visited when the user presses the Tab key.
Initially, the tab order is always the order in which the controls were added to the form.
Auto Tab Order - Programmatically
How many times have you "inserted" a visual component (control) between two control - and have forgotten to fix the tab order of the controls?
The SetChildTaborders function will programmatically fix the TabOrder property to all child controls for a given Parent.
Procedure SetChildTaborders(const Parent: TWinControl) ;

procedure FixTabOrder(const Parent: TWinControl) ;
var
ctl, L: Integer;
List: TList;
begin
List := TList.Create;
try
for ctl := 0 to Parent.ControlCount - 1 do
begin
if Parent.Controls[ctl] is TWinControl then
begin
if List.Count = 0 then
L := 0
else
begin
with Parent.Controls[ctl] do
for L := 0 to List.Count - 1 do
if (Top or ((Top = TControl(List[L]).Top) and (Left then Break;
end;

List.Insert(L, Parent.Controls[ctl]) ;
FixTabOrder(TWinControl(Parent.Controls[ctl])) ;
end;
end;

for ctl := 0 to List.Count - 1 do
TWinControl(List[ctl]).TabOrder := ctl;
finally
List.Free;
end;
end;
begin
FixTabOrder(Parent) ;
end;

Note: TabOrder is meaningful only if the TabStop property is true.