Change focus to other component

Posted in Components

This example shows changing of focus between three components on a button click.

var
  i: Integer = 2;
...
procedure TForm1.Button1Click(Sender: TObject);
begin
  case (i mod 3) of
    1: Edit1.SetFocus;
    2: Memo1.SetFocus;
    0: ListBox1.SetFocus;
  end;
  Inc(i);
end;