可不可以写很少的代码就清除窗体中所有TEdit中的文字,而不需写Edit1.text:=;Edit2.Text:=;.............
var i:integer;
begin
for i:= 0 to form1.componentcount-1 do //不好意思componentcount记不太清!!
if components[i] is Tedit then //遍历窗体的所有控件,并判断是否是Tedit类型的.
(components[i] as Tedit).text:=;//如果是则把它清空
end;
如果错误,真的很抱歉!!!但是基本上是这样.
for i := 0 to ComponentCount - 1 do
begin
if Components[i] is TsuiEdit then
(Components[i] as TsuiEdit).Text := ;
if Components[i] is TsuiCheckBox then
(Components[i] as TsuiCheckBox).Checked := False;
if Components[i] is TsuiCheckListBox then
(Components[i] as TsuiCheckListBox).Items.Clear;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
for i:=0 to form1.ComponentCount-1 do
if Components[i] is tedit then (components[i] as tedit).Text:=;
end;
for i:=0 to form1.ComponentCount-1 do
if Components[i] is tedit then (components[i] as tedit).Text:=;
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
begin
for i:=1 to 2 do
TEdit(FindComponent(Edit+IntToStr(i))).Clear;
end;
for i := 0 to ComponentCount - 1 do
begin
if Components[i] is TsuiEdit then
(Components[i] as TsuiEdit).Text := ;
if Components[i] is TsuiCheckBox then
(Components[i] as TsuiCheckBox).Checked := False;
if Components[i] is TsuiCheckListBox then
(Components[i] as TsuiCheckListBox).Items.Clear;
end;