The following code snippet will reset the Text
value of all TEdit
objects (and other descendants of TCustomEdit
, such as TLabeledEdit
, TMaskEdit
or TMemo
) found on the form. Thus, after pressing the "Save" button, the entire screen will be cleared.
Additionally you can use DB objects for this. Thus, the relevant fields will be reset automatically after the Append/Post
operation. Another recommendation is that if the screen will close after the "Save" button, the free agent of the relevant form will reset all objects again. You will need to create that form while opening it, and you need to send it to the "Available forms" side from Project -> Options -> Forms
so that it does not auto-create.
procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
begin
for I := 0 to Self.ComponentCount - 1 do
begin
if Self.Components[I] is TCustomEdit then
begin
(Self.Components[I] as TCustomEdit).Text := '';
end;
end;
end;
TEdit.Text
to an empty String? – AmigoJackTCustomEdit
has a publicClear()
method.: "Deletes all text from the edit control." – Remy Lebeau