Let's talk about the tnewchecklistbox class today.
This class is similar to ListBox, but the following items can be selected using checkbox or radiobutton, which is a complex type.
This class inherits from Tcustomlistbox has the following attributes and functions:
Tnewchecklistbox = Class (tcustomlistbox) function addcheckbox (const acaption, asubitem: string; alevel: byte; achecked, aenabled, ahasinternalchildren, struct: 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: tpolicyevent; read write; property borderstyle: tborderstyle; read write; property color: tcolor; read write; property Font: tfont; read write; property sorted: Boolean; read write; property onclick: tpolicyevent; read write; property ondblclick: tpolicyevent; 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
Test example:
[Code] varmypage: 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, 'title: Custom page', 'description: this is my custom page '); LBL: = tlabel. create (mypage); LBL. parent: = mypage. surface; clb1: = tnewchecklistbox. create (mypage); clb1.width: = mypage. surfacewidth; clb1.top: = 20; clb1.height: = scale( 200); clb1.flat: = true; clb1.parent: = mypage. surface; clb1.addcheckbox ('operating system ',', 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 ('installable components', '', 0, true, true, false, true, nil); clb1.addcheckbox ('component 1','', 1, true, true, false, true, nil); clb1.addcheckbox ('component 2', '', 1, true, true, false, true, nil ); clb1.addcheckbox ('component 3', '', 1, false, true, false, true, nil); clb1.onclickcheck :=@ clbclickcheck; end; the running effect is as follows:
TheProcedure clbclickcheck dynamically adjusts automatically according to the selected options.
From: http://www.360doc.com/content/13/0327/14/4221543_274238357.shtml