Let’s say you have a data entry form or a MP3 ID3 tag editor form. The user clicks the “Clear” button. The more edit controls you have the less you want to write the code to clear them
Well, here’s a better idea:
procedure TMainForm.btnClear(Sender: TObject);
var
iI: Integer;
begin
for iI := 0 to ComponentCount - 1 do
if (Components[iI] is TEdit) then
TEdit(Components[iI]).Clear;
end;
If you want to exclude a edit control from being cleared use this:
!!Note: The name check must be after the VCL class check.
if (Components[iI] is TEdit) and (TEdit(Components[iI].Name <> 'edDontClear')) then TEdit(Components[iI]).Text := '';
Tags: access, array, borland, change, clear, code, codegear, controls, data entry, Delphi, edit, edit control, id3, Kylix, mp3, property, refering, s, source, tedit, vcl, write
Merlin’s Delphi Forge
Leave a comment