procedure TForm1.Button1Click(Sender: TObject);
var i,j:integer;
begin
for i:=0 to Form1.ComponentCount-1 do
begin
if Form1.Components[i] is tedit then
begin
if ((form1.components[i] as tedit).name='a') or ((form1.components[i] as tedit).name='b') then
(form1.components[i] as tedit).text:='';
end;
if Form1.Components[i] is tcombobox then
begin
if ((form1.components[i] as tcombobox).name='c') or ((form1.components[i] as tcombobox).name='d') then
(form1.components[i] as tcombobox).itemindex:=-1;
end;
end;
end;
var i,j:integer;
begin
for i:=0 to Form1.ComponentCount-1 do
begin
if Form1.Components[i] is tedit then
begin
if ((form1.components[i] as tedit).name='a') or ((form1.components[i] as tedit).name='b') then
(form1.components[i] as tedit).text:='';
end;
if Form1.Components[i] is tcombobox then
begin
if ((form1.components[i] as tcombobox).name='c') or ((form1.components[i] as tcombobox).name='d') then
(form1.components[i] as tcombobox).itemindex:=-1;
end;
end;
end;
为这4个构件各自做一个标签 是为他们加上label么?
看后面有不象。又好象是给他们text复值