Author: William Gerbert
How to remove all components of a certain type at run time
Answer:
1 //implementation:2 3 procedure Tform1.freeInstances(aClass: TClass);
4 var5 i: Integer;
6 begin7 for i := formFacture.ControlCount - 1 downto 0 do8 if (Controls[i] is aClass) then9 begin10 (Controls[i] as aClass).Free;
11 //instead of free you can put anything you need here12 end;
13 end;
14 15 //calling:16 17 procedure Tform1.Button1Click(Sender: TObject);
18 begin19 freeInstances(TEdit); //will free all tedit on form120 end;