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

列表框

列表框(ListBox)是Windows应用程序中重要的输入手段,其中包括多个选项用户可以从其中选择一个或者多个,程序根据用户的选择做出相应的处理,列表框在外观上和存储框类似,但是行为却有很大的不同,列表框中项一般是预先给定的,而存储框则可以让用户进行输入,并且列表框中的项被选择之后也会触发事件。Pascal脚本中列表框的类由TlistBox实现,其定义如下:

TListBox = class(TCustomListBox)

property BorderStyle: TBorderStyle; read write;

property Color: TColor; read write;

property Font: TFont; read write;

property MultiSelect: Boolean; read write;

property Sorted: Boolean; read write;

property Style: TListBoxStyle; 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;

end;

层次模型如下:

下面的代码将演示列表框的使用:

[setup]

AppName=Test

AppVerName=TEST

DefaultDirName="E:\TEST"

AppVersion=1.0

[files]

Source:zzz.iss;Flags:dontcopy

[code]

var

myPage:TWizardPage;

list:TListBox;

lbl:TLabel;

procedure ClickListBox(Sender:TObject);

begin

lbl.Caption:='你选择的城市是:'+list.Items.Strings[list.ItemIndex]

end;

procedure InitializeWizard();

begin

myPage:=CreateCustomPage(wpWelcome, '标题:自定义页面', '描述:这是我的自定义页面');

list:=TListBox.Create(myPage);

list.Parent:=myPage.Surface;

list.Items.Add('北京');

list.Items.Add('上海');

list.Items.Add('香港');

list.Items.Add('武汉');

list.Items.Add('广州');

list.OnClick:=@ClickListBox;

lbl:=TLabel.Create(myPage);

lbl.Parent:=myPage.Surface;

lbl.Top:=list.Top+list.Height+10;

end;

list.ItemIndex返回列表框中选中项索引值,Items.Strings[list.ItemIndex]则是返回该索引值指代项的字符串值,安装页面如下:

另外,列表框也有MultiSelect选项,表示列表框是否支持多选(在支持的前提下,需要按Ctrl键),但是这种性能并不是太好,个人觉得这个时候还不如用多选框效果更好。

最新文章

  1. 【Django】--Form组件
  2. Go语言异常处理defer\panic\recover
  3. python不用加号实现加法
  4. Git command line
  5. C语言的内存管理
  6. 1.html5究竟是什么
  7. php整理(一):变量和字符串
  8. python实现的基于TCP的JSON数据通信
  9. etTimeout与setInterval方法的区别
  10. 结构性产品 Structured Product
  11. 条款20:宁以pass-by-reference-to-const替换pass-by-value
  12. 小米2s的座充,看看这个是什么芯片? - 电池&综合DIY(Flashlight Electronics-Batteries Include - 手电大家谈-手电筒爱好者之家
  13. gitbook 入门教程之 gitbook 简介
  14. Java8 LocalDateTime获取时间戳(毫秒/秒)、LocalDateTime与String互转、Date与LocalDateTime互转
  15. 微信小程序 从含有tabbar的页面跳转到不含有tabbar的页面
  16. enquire.js-响应css媒体查询的轻量级javascript库
  17. jdk中的简单并发,需要掌握
  18. Python中xlwt解析
  19. java中父进程与子进程
  20. for XX in XX结构

热门文章

  1. Educational Codeforces Round 23 补题小结
  2. UNIX shell 学习笔记 一 : 几个shell的规则语法对比
  3. AspxGridView 表中的ASPxHyperLink不导出到excel
  4. tornado 模版
  5. redis的安装和php的redis扩展
  6. _stdcall调用
  7. hdu 1026(优先队列+路径输出)
  8. Search in Rotated Sorted Array I&&II——二分法
  9. [BZOJ4456] [Zjoi2016]旅行者 分治+最短路
  10. react native 调用Android原生方法