http://379910987.blog.163.com/blog/static/3352379720126693742406/

今天说说TNewCheckListBox类。
该类和ListBox差不多,只是下面的项可以用CheckBox或者RadioButton选择,是一种比较复杂的类型。

该类继承自TCustomListBox,自身具有以下属性和函数: 
TNewCheckListBox = class(TCustomListBox)
  function AddCheckBox(const ACaption, ASubItem: String; ALevel: Byte; AChecked, AEnabled, AHasInternalChildren, ACheckWhenParentChecked: Boolean; AObject: TObject): Integer;
  function AddGroup(ACaption, ASubItem: String; ALevel: Byte; AObject: TObject): Integer;
  function AddRadioButton(const ACaption, ASubItem: String; ALevel: Byte; AChecked, AEnabled: Boolean; AObject: TObject): Integer;
  function CheckItem(const Index: Integer; const AOperation: TCheckItemOperation): Boolean;
  property Checked[Index: Integer]: Boolean; read write;
  property State[Index: Integer]: TCheckBoxState; read write;
  property ItemCaption[Index: Integer]: String; read write;
  property ItemEnabled[Index: Integer]: Boolean; read write;
  property ItemLevel[Index: Integer]: Byte; read;
  property ItemObject[Index: Integer]: TObject; read write;
  property ItemSubItem[Index: Integer]: String; read write;
  property AllowGrayed: Boolean; read write;
  property Flat: Boolean; read write;
  property MinItemHeight: Integer; read write;
  property Offset: Integer; read write;
  property OnClickCheck: TNotifyEvent; read write;
  property BorderStyle: TBorderStyle; read write;
  property Color: TColor; read write;
  property Font: TFont; read write;
  property Sorted: Boolean; read write;
  property OnClick: TNotifyEvent; read write;
  property OnDblClick: TNotifyEvent; read write;
  property OnKeyDown: TKeyEvent; read write;
  property OnKeyPress: TKeyPressEvent; read write;
  property OnKeyUp: TKeyEvent; read write;
  property ShowLines: Boolean; read write;
  property WantTabs: Boolean; read write;
  property RequireRadioSelection: Boolean; read write;
end

测试例子:

[code]
var
myPage:TWizardPage;
    clb1, clb2: TNewCheckListBox;
    lbl: TLabel;
    i,index:Integer;

procedure clbClickCheck(Sender: TObject);
begin
  lbl.Caption:='';
  for i:=1 to 3 do
    if clb1.Checked[i] then
        lbl.Caption:=clb1.ItemCaption[i]+'  '; 
        
    for i:=5 to 7 do
        if clb1.Checked[i] then
            lbl.Caption:=lbl.Caption+clb1.ItemCaption[i]+' ';
 
end;
 
procedure InitializeWizard();
begin
    myPage:=CreateCustomPage(wpWelcome, '标题:自定义页面', '描述:这是我的自定义页面');
    
    lbl:=TLabel.Create(myPage);
    lbl.Parent:=myPage.Surface;
    
    clb1 := TNewCheckListBox.Create(mypage);
clb1.Width := mypage.SurfaceWidth;
clb1.Top:=20;
clb1.Height := ScaleY(200);
clb1.Flat := True;
clb1.Parent := mypage.Surface;
clb1.AddCheckBox('操作系统', '', 0, True, True, False, True, nil);
clb1.AddRadioButton('Windows 2000', '', 1, False, True, nil);
clb1.AddRadioButton('Windows XP', '', 1, True, True, nil);
clb1.AddRadioButton('Windows 7', '', 1, False, True, nil);
clb1.AddCheckBox('可安装组件', '', 0, True, True, False, True, nil);
 
clb1.AddCheckBox('组件1', '', 1, True, True, False, True, nil);
    clb1.AddCheckBox('组件2', '', 1, True, True, False, True, nil);
    clb1.AddCheckBox('组件3', '', 1, False, True, False, True, nil);
    clb1.OnClickCheck:=@clbClickCheck;   
end;
运行效果如下:

其中的 procedure clbClickCheck将动态地根据所选项进行自动调整。

最新文章

  1. out
  2. UIDynamic(简单介绍)
  3. jQuery 菜单栏 展开与收缩例子
  4. UI第一节—— UILable
  5. css3 弹框功能样式
  6. JSP Request方法大全
  7. 【PHP高效搜索专题(2)】sphinx&coreseek在PHP程序中的应用实例
  8. EDM(邮件营销)
  9. 2013第38周日Java文件上传下载收集思考
  10. Js中call apply函数以及this用法
  11. Jemter性能测试
  12. [玩耍]C++控制台扫雷
  13. 通过线程监控socket服务器是否done机
  14. AngularJS学习篇(十八)
  15. maven核心概念--插件和目标
  16. Description Resource Path Location Type Project configuration is not up-to-date with pom.xml. Select: Maven->Update Project... from the project context menu or use Quick Fix. spark-MT line 1 Maven Co
  17. maya cmds pymel polyEvaluate 获取 bounding box
  18. Docker 加速器设置
  19. OpenStack容器网络项目Kuryr(libnetwork)
  20. 中文全文检索讯搜xunsearch安装

热门文章

  1. python实战===爬取所有微信好友的信息
  2. tableView选中行的调用顺序/ 取消选中Cell
  3. SVN服务的配置与管理
  4. SQL语句获取时间的方法
  5. Vim配置Node.js开发工具
  6. java 查看运行时某个类文件所在jar的位置
  7. JavaScript中常用的BOM属性
  8. django开发项目实例2--如何链接图片和css文件(静态文件)
  9. Django 项目CRM总结
  10. 原生DOM选择器querySelector和querySelectorAll