求助::有30个checkbox分成10个组,每组3个.如何实现每组至少有个checkbox是
checked.是不是要用到那个函数啊?怎么分组?好像用Groupbox不行?
可能这个问题有点菜,还请大家帮帮我这菜鸟!!!!谢谢!!!
checked.是不是要用到那个函数啊?怎么分组?好像用Groupbox不行?
可能这个问题有点菜,还请大家帮帮我这菜鸟!!!!谢谢!!!
解决方案 »
- delphi中对sql server数据库的查询(应该很简单)
- 请问Ehlib中如何才能打印出页码来?
- 按装控件时提示DsgnIntf.dcu找不到
- 怎么样禁止输入重复记录呢?
- 如何提高查询速度?
- 那位朋友知道如何在网络上截取一个信息(数据包)
- 关于捕捉WinSocket编程中异常的问题!
- 哪位使用过“csdn论坛助手”这个软件,我下载一个试了试,好像没有什么反映,哪位给点建议
- 需要outlook风格的可滑动的左侧工具栏控件(100分)答者有分!
- 小问题,紧急求援。
- delphi中用STOREDPROC调用SQL2000中的INSERT存储过程,报以下错,求教,谢谢?
- 哪里下载dev dxdbgrid(delphi5)?
var
i: Integer;
begin
for i := 0 to GroupBox1.ComponentCount - 1 do
begin
if TCheckBox(GroupBox1.Components[i]).Checked then
begin
Result := True;
break;
exit;
end;
end;
Result := False;
end;
我试了一下
GroupBox1.ComponentCount 取不出来-_-!
在一个GroupBox组里有3个CheckBox:
至少有一个CheckBox是Checked ^_^
function isChecked(ParentControl: TWinControl): Boolean;
var
i: Integer;
s: boolean;
begin
for i := 0 to ParentControl.ControlCount - 1 do
begin
s := TCheckBox(ParentControl.Controls[i]).Checked;
if s then
begin
Result := True;
exit;
break;
end;
end;
Result := False;
end;procedure TForm1.CheckBox1Click(Sender: TObject);
begin
if not isChecked(GroupBox1) then
CheckBox1.Checked := True;
end;procedure TForm1.CheckBox2Click(Sender: TObject);
begin
if not isChecked(GroupBox1) then
CheckBox2.Checked := True;
end;procedure TForm1.CheckBox3Click(Sender: TObject);
begin
if not isChecked(GroupBox1) then
CheckBox3.Checked := True;
end;
这个函数你加上了吗?
你不要在上面声明。
整个单元如下:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
GroupBox1: TGroupBox;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
procedure CheckBox1Click(Sender: TObject);
procedure CheckBox2Click(Sender: TObject);
procedure CheckBox3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
function isChecked(ParentControl: TWinControl): Boolean;
var
i: Integer;
s: boolean;
begin
for i := 0 to ParentControl.ControlCount - 1 do
begin
s := TCheckBox(ParentControl.Controls[i]).Checked;
if s then
begin
Result := True;
exit;
break;
end;
end;
Result := False;
end;procedure TForm1.CheckBox1Click(Sender: TObject);
begin
if not isChecked(GroupBox1) then
CheckBox1.Checked := True;
end;procedure TForm1.CheckBox2Click(Sender: TObject);
begin
if not isChecked(GroupBox1) then
CheckBox2.Checked := True;
end;procedure TForm1.CheckBox3Click(Sender: TObject);
begin
if not isChecked(GroupBox1) then
CheckBox3.Checked := True;
end;end.