Author: Tomas Rutkauskas How to create a TAction and its OnExecute event at runtime Answer: 1 { ... } 2 type 3 TForm1 = class(TForm) 4 ActionList1: TActionList; 5 procedure FormCreate(Sender: TObject); 6 private 7 Action1, Action2: TAction; 8 procedure Test(Sender: TObject); 9 end; 10 11 procedure TForm1.Test(Sender: TObject); 12 begin 13 Caption := IntToStr(Actionlist1.ActionCount); 14 end; 15 16 procedure TForm1.FormCreate(Sender: TObject); 17 begin 18 Action1 := TAction.Create(Actionlist1); 19 Action1.Actionlist := Actionlist1; 20 Action1.OnExecute := Test; 21 Form1.OnClick := Action1.OnExecute; 22 end;