i ; integer;
for i := 0 to form1.ControlCount-1 do
begin
if form1.Controls is tedit then (form1.Controls as tedit).text :=''
else if form1.Controls is tcombobox then (form1.Controls as tcombobox).text :=''
end;
for i := 0 to Form1.ComponentCount - 1 do
begin
if Form1.Components is TEdit then
begin
TEdit(Form1.Components).Text:='';
Continue;
end;
if Form1.Components is TComboBox then
begin
TComboBox(Form1.Components).Text:='';
end;
end;
for i := 0 to Form1.ComponentCount - 1 do
begin
if Form1.Components is TEdit then
begin
TEdit(Form1.Components).Text:='';
end;
if Form1.Components is TComboBox then
begin
TComboBox(Form1.Components).Text:='';
end;
end;
to xhlight
你这种free方法是错的,不知道你试过没有;应该改为如下方法:
j:= 0;
for I:=0 to CompenentCount-1 do
begin
if (Compenents[j] is TEdit) or (Compenents[j] is TComboBox) then
Compenents[j].Free
else j:=j+1;
end;