Wednesday, March 2, 2011

How to clear multiple edit controls without having to refer to them one by one

So your new form has 40 edit controls, and now you're looking for a quick and easy way to clear all of them without having to refer to them one by one. How about using a function like this:

procedure TForm1.Button1Click(Sender: TObject);
var
  i : integer;
begin
  for i := 0 to ComponentCount-1 do
    begin
      if( Components[ i ] is TEdit )then
      begin
        (Components[ i ] as TEdit).Text := '';
      end;
  end;
end;

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Kang Iwan K-sev | Thank's for your visit To My Site - Ridwan Mulyana | Cibeureum