控件为: CheckBox1 到 CheckBox100条件为:
procedure ?(?);
begin if CheckBox1.Checked thenCheckBox2.Checked and CheckBox4.Checked and CheckBox6.Checked ......到CheckBox50.Checked Checked:=true;状态Label1.Color:=clRed and Label3.Color:=clRed and Label51.Color:=clRed......到 Label51.Color:=clRed;要写为一个自定义的参数,,,到时可以调用procedure TForm1.Button2Click(Sender: TObject);
begin
procedure ?(?);
end;没分了,只有80分.......调试成功,谁先答就给谁....代码要完整.
procedure ?(?);
begin if CheckBox1.Checked thenCheckBox2.Checked and CheckBox4.Checked and CheckBox6.Checked ......到CheckBox50.Checked Checked:=true;状态Label1.Color:=clRed and Label3.Color:=clRed and Label51.Color:=clRed......到 Label51.Color:=clRed;要写为一个自定义的参数,,,到时可以调用procedure TForm1.Button2Click(Sender: TObject);
begin
procedure ?(?);
end;没分了,只有80分.......调试成功,谁先答就给谁....代码要完整.
i:integer;
begin
if checkbox1.checked then
for i:=2 to 50 do
with (self.findcomponent('checkbox'+inttostr(i)) as TCheckbox) do
checked:=true
end;
end;end;
i:integer;
begin
if checkbox1.checked then
for i:=2 to 50 do
with (self.findcomponent('checkbox'+inttostr(i)) as TCheckbox) do
checked:=true
end;
end;for i:=1 to 51 do
with (self.findcomponent('label'+inttostr(i)) as Tlable) do
Color:=clRed ;
end;
end;
end;
/将需要进行状态判断的TCheckBox的Tag属性设置成一个固定的值,如100function getChecked: Boolean;
var
i: Integer;
checkbox: TCheckBox;
begin
result := true;
for I := 0 to ComponentCount - 1 do
if (Components[I] is TCheckBox) and (TCheckBox(Components[I]).tag = 100) and
(not TCheckBox(Components[I]).Checked) then
begin
result := false;
break;
end;
end;
//批量设置TLabel
//将需要统一修改Color的Label的Tag设置成一个固定值,如100procedure SetLabelColor;
var
I: Integer;
begin
for I := 0 to ComponentCount - 1 do
if (Components[I] is TLabel) and (TLabel(Components[I]).tag = 100) then
TLabel(Components[I]).Color := clRed;
end;
begin
CheckBox2.Checked:=true;
CheckBox4.Checked:=true;
CheckBox6.Checked:=true;
CheckBox8.Checked:=true;
CheckBox10.Checked:=true;
CheckBox12.Checked:=true;
CheckBox14.Checked:=true;
CheckBox16.Checked:=true;
CheckBox18.Checked:=true;
CheckBox20.Checked:=true;
CheckBox22.Checked:=true;
CheckBox24.Checked:=true;
CheckBox26.Checked:=true;
CheckBox28.Checked:=true;
CheckBox30.Checked:=true;
CheckBox32.Checked:=true;
CheckBox34.Checked:=true;
CheckBox36.Checked:=true;
CheckBox38.Checked:=true;
CheckBox40.Checked:=true;
CheckBox42.Checked:=true;
CheckBox44.Checked:=true;
CheckBox46.Checked:=true;
CheckBox48.Checked:=true;
CheckBox50.Checked:=true;
end
else
if CheckBox1.Checked then
begin
CheckBox1.Checked:=true;
CheckBox3.Checked:=true;
CheckBox5.Checked:=true;
CheckBox7.Checked:=true;
CheckBox9.Checked:=true;
CheckBox11.Checked:=true;
CheckBox13.Checked:=true;
CheckBox15.Checked:=true;
CheckBox17.Checked:=true;
CheckBox19.Checked:=true;
CheckBox21.Checked:=true;
CheckBox23.Checked:=true;
CheckBox25.Checked:=true;
CheckBox27.Checked:=true;
CheckBox29.Checked:=true;
CheckBox31.Checked:=true;
CheckBox33.Checked:=true;
CheckBox35.Checked:=true;
CheckBox37.Checked:=true;
CheckBox39.Checked:=true;
CheckBox41.Checked:=true;
CheckBox43.Checked:=true;
CheckBox45.Checked:=true;
CheckBox47.Checked:=true;
CheckBox49.Checked:=true;
end;
var
i:integer;
MySet:Set of (2,4,6,8,10)//把需要设置为true的序号放到集合内
begin//在这里可以事先使用集合的操作方法定义你需要的集合元素
//比如12也要为ture,那么就可以myset:=myset+[12]的方法把12也添加到集合内if checkbox1.checked then
for i:=2 to 50 do
if i in Myset then
begin
with (self.findcomponent('checkbox'+inttostr(i)) as TCheckbox) do
checked:=true
end
end;
end;//label也一样,可以再定义一个集合,这里我就不重复了
for i:=1 to 51 do
with (self.findcomponent('label'+inttostr(i)) as Tlable) do
Color:=clRed ;
end;
end;
end;