cxCheckCombobox里实现checked和获取Itemindex
今天用cxCheckCombobox,准备获取cxCheckCombobox里所有被checked的Items的Itemindex,通过个人的思考和从网络上获取的参考,用cxCheckCombobox实现以上功能主要有两种方法。如下:
uses
cxLookAndFeelPainters;
………
var
Form1: TForm1;
&nbs...
今天用cxCheckCombobox,准备获取cxCheckCombobox里所有被checked的Items的Itemindex,通过个人的思考和从网络上获取的参考,用cxCheckCombobox实现以上功能主要有两种方法。如下:
uses
cxLookAndFeelPainters;
………
var
Form1: TForm1;
S : string;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
I : Integer;
begin
S := '';
for I := 0 to cxCheckComboBox1.Properties.Items.Count - 1 do
begin
if cxCheckComboBox1.States[I]=cbschecked then
S := S + IntToStr(I);
end;
ShowMessage(S);
end;
procedure TForm1.Button2Click(Sender: TObject);
Var
I : Integer;
begin
S := '';
for I := 0 to cxCheckComboBox1.Properties.Items.Count - 1 do
begin
if cxCheckComboBox1.Properties.Items[I].Tag=1 then
S := S + IntToStr(I);
end;
ShowMessage(S);
end;
procedure TForm1.cxCheckComboBox1PropertiesClickCheck(Sender: TObject;
ItemIndex: Integer; var AllowToggle: Boolean);
begin
if cxCheckComboBox1.Properties.Items[ItemIndex].Tag=0 then
cxCheckComboBox1.Properties.Items[ItemIndex].Tag:=1
else
cxCheckComboBox1.Properties.Items[ItemIndex].Tag:=0;
end;
procedure TForm1.FormCreate(Sender: TObject);
Var
I : Integer;
begin
for I := 0 to cxCheckComboBox1.Properties.Items.Count - 1 do
begin
cxCheckComboBox1.Properties.Items[I].Tag :=0;
end;
end;
注意:在判断cxCheckComboBox1.States[I]的状态时,一定要在uses里添加cxLookAndFeelPainters。该状态是一个枚举,有三个分别为;选中:cbsChecked ,不选中:cbsUnchecked,灰色:cbsGrayed
微信或手机浏览器扫一扫,随时随地随心阅读与分享
文章标题:cxCheckCombobox里实现checked和获取Itemindex
文章链接:https://www.14551.cn/Delphi/737.html
版权声明:本站提供的一切软件、教程和内容信息仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络收集整理,如果您喜欢该程序和内容,请支持正版,购买注册,得到更好的正版服务。我们非常重视版权问题,如有侵权请邮件与我们联系处理。敬请谅解!




发表评论