Topic: Clear text in all text box of a form

Hello everyone and thank you for reading my request. In a button I gave these instructions to delete all the text of each text box of a form:

procedure frmAvvio_Button1_OnClick (Sender: TObject; var Cancel: boolean);
  var
  i : integer;
begin
  for i:= 0 to ComponentCount -1 do
     if Components[i] is TEdit then TEdit (Components[i]).Clear;
end;

But it does not work. It tells me: Undeclared identifier: 'ComponentCount'

Thanks to all and a greeting.

2 (edited by sparrow 2023-03-14 20:45:24)

Re: Clear text in all text box of a form

Hi,
Right syntax -
frmAvvio.ComponentCount
frmAvvio.Components
TdbEdit



procedure frmAvvio_Button1_OnClick (Sender: TObject; var Cancel: boolean);
 var
  i : integer;
begin
  for i:= 0 to frmAvvio.ComponentCount -1 do
     if frmAvvio.Components[i] is TdbEdit then TdbEdit(frmAvvio.Components[i]).Clear;
end;

3 (edited by reteinformatica 2023-03-14 20:48:13)

Re: Clear text in all text box of a form

Oh what a trivial mistake. Thanks very much sparrow.
What is TdbEdit's equivalent for comboox?

Re: Clear text in all text box of a form

http://myvisualdatabase.com/help_en/ComboBox.html


TdbComboBox

Re: Clear text in all text box of a form

Example
clear all components on form
Choose what you need


http://myvisualdatabase.com/forum/viewt … 667#p18667

Re: Clear text in all text box of a form

Well, thank you very much, I didn't know that page. Is there an istructions set to clear all results in a table grid?

7 (edited by sparrow 2023-03-14 21:02:51)

Re: Clear text in all text box of a form

IF Form.Components[i] is TdbStringGridEx Then TdbStringGridEx(Form.Components[i]).ClearRows;

http://myvisualdatabase.com/help_en/scr … egrid.html

Re: Clear text in all text box of a form

Thank you very much sparrow I did what I needed.
Long live Ukraine

Re: Clear text in all text box of a form

Thanks