用CheckListBox1.Checked[n]来判断某项是否选中。 比如: procedure TForm1.CheckListBox1Click(Sender: TObject); begin if CheckListBox1.Checked[CheckListBox1.ItemIndex] = True then begin ShowMessage('当前项为被选中状态'); end; end;
procedure TForm1.Button1Click(Sender: TObject); begin if (CheckListBox1.Checked[CheckListBox1.Items.IndexOf('a')]) and (not CheckListBox1.Checked[CheckListBox1.Items.IndexOf('b')]) then begin ShowMessage('a Checked'); end; if (not CheckListBox1.Checked[CheckListBox1.Items.IndexOf('a')])and (CheckListBox1.Checked[CheckListBox1.Items.IndexOf('b')]) then begin ShowMessage('b Checked'); end; if (CheckListBox1.Checked[CheckListBox1.Items.IndexOf('a')])and (CheckListBox1.Checked[CheckListBox1.Items.IndexOf('b')]) then begin ShowMessage('a、b Checked'); end; end;
if form1.CheckListBox1.Checked[1] and form1.CheckListBox1.Checked[2] then showmessage('你选中了第2和第3项');
Kevin_Lmx(繁华阅尽) 你可真快手啊!.....^_^
我好晕哪,呵呵。 gxgyj(杰克.逊)别来无恙? ^_^
case CheckListBox1.Checked of true:do something .... end; case CheckListBox2.Checked of true:do something .... end;
这样吧 procedure TForm1.CheckListBox1Click(Sender: TObject); var I : Integer; str: String; begin for I:=0 to CheckListBox1.Items.Count-1 do begin if CheckListBox1.Checked[I] then Str := Str + CheckListBox1.Items.Strings[I]; end; if Str='a' then begin ...... end if Str='b' then begin ...... end if Str='ab' then begin ...... end if str=....... end;
这样说吧.. 比如有3个Items.分别为a,b.c 单选A时候 DO 事件1; 单选B时候 DO 事件2; 同时选A,B时候 DO 事件3; 同时选A,C时候 DO 事件4; 同时选A,B,C时候 DO 事件5;Items少的时候还好...我现在是五项就已经有够多可能了..再多怎么办呀?? 一定要先全列出所有可能性么??
比如:
procedure TForm1.CheckListBox1Click(Sender: TObject);
begin
if CheckListBox1.Checked[CheckListBox1.ItemIndex] = True then
begin
ShowMessage('当前项为被选中状态');
end;
end;
这样说吧..
有2个Items.分别为a,b.
单选A时候DO 事件1;
单选B时候DO 事件2;
同时选A,B时候DO 事件3;而且我的事件代码应该是写在Buttonclick里..不是CheckListBox1Click
这样说明白么??
begin
if (CheckListBox1.Checked[CheckListBox1.Items.IndexOf('a')]) and
(not CheckListBox1.Checked[CheckListBox1.Items.IndexOf('b')]) then
begin
ShowMessage('a Checked');
end;
if (not CheckListBox1.Checked[CheckListBox1.Items.IndexOf('a')])and
(CheckListBox1.Checked[CheckListBox1.Items.IndexOf('b')]) then
begin
ShowMessage('b Checked');
end;
if (CheckListBox1.Checked[CheckListBox1.Items.IndexOf('a')])and
(CheckListBox1.Checked[CheckListBox1.Items.IndexOf('b')]) then
begin
ShowMessage('a、b Checked');
end;
end;
showmessage('你选中了第2和第3项');
你可真快手啊!.....^_^
gxgyj(杰克.逊)别来无恙?
^_^
true:do something ....
end;
case CheckListBox2.Checked of
true:do something ....
end;
procedure TForm1.CheckListBox1Click(Sender: TObject);
var
I : Integer;
str: String;
begin
for I:=0 to CheckListBox1.Items.Count-1 do
begin
if CheckListBox1.Checked[I] then
Str := Str + CheckListBox1.Items.Strings[I];
end;
if Str='a' then
begin
......
end
if Str='b' then
begin
......
end
if Str='ab' then
begin
......
end
if str=.......
end;
比如有3个Items.分别为a,b.c
单选A时候 DO 事件1;
单选B时候 DO 事件2;
同时选A,B时候 DO 事件3;
同时选A,C时候 DO 事件4;
同时选A,B,C时候 DO 事件5;Items少的时候还好...我现在是五项就已经有够多可能了..再多怎么办呀??
一定要先全列出所有可能性么??
我实际就是5种图表..
客户选了几个我就在DBChart上画出那几个图表来...
如:单选A就执行事件A
单选B就执行事件B...
那么选择A和B不就是先执行事件A再执行事件B就可以了吗?难道这时是执行事件C吗?
选择A和B我不是要作A.B两件事情.
而是作另外的第三件事情..