groupbox组件下有4个checkbox组件
radiogroup有4个radio,caption分别为1、2、3、4
请问在选择radiogroup中的2,groupbox只能选择2个checkbox,请问程序如何实现?
radiogroup有4个radio,caption分别为1、2、3、4
请问在选择radiogroup中的2,groupbox只能选择2个checkbox,请问程序如何实现?
procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
if RadioGroup1.Items[RadioGroup1.ItemIndex]='2' then
SetEnabled(False);
end;procedure TForm1.SetEnabled(bV: Boolean);
begin
CheckBox1.Enabled:=bv;
CheckBox2.Enabled:=bv;
end;
function TForm1.CanChecked(const totalCheck: Integer): boolean;
var
checkedCount : Integer;
I : Integer;
begin
checkedCount := 0;
for I := 0 to Grp1.ControlCount -1 do
begin
if grp1.Controls[I] is TCheckBox then
if TCheckBox(grp1.Controls[I]).Checked then
INC(checkedCount);
end;
Result := (checkedCount < totalCheck);
end;procedure TForm1.Enabledgrpbx(const Value: Boolean);
var
I : Integer;
begin
for I := 0 to grp1.ControlCount -1 do
begin
grp1.Controls[i].Enabled := value;
end;
end;procedure TForm1.rg1Click(Sender: TObject);
begin
Enabledgrpbx(CanChecked(strtoint(rg1.Items[rg1.ItemIndex])));
end;
不知道能不能对你有所帮助
那两个?
有没有规则?