This article Reprinted from: http://blog.csdn.net/yushanddddfenghailin/article/details/17268473
List box
ListBox is an important input method in Windows applications. It includes multiple options. You can select one or more options, and the program processes the selected items accordingly, the appearance of a list box is similar to that of a storage box, but its behavior is very different. items in the list box are generally pre-defined, while the storage box allows users to input, when an item in the list box is selected, an event is triggered. The ListBox class in the Pascal script is implemented by tlistbox. Its definition is as follows:
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: tpolicyevent; read write;
Property ondblclick: tpolicyevent; read write;
Property onkeydown: tkeyevent; read write;
Property onkeypress: tkeypressevent; read write;
Property onkeyup: tkeyevent; read write;
End;
The hierarchical model is as follows:
The following code demonstrates the use of the list box:
[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: = 'The city you selected is: '+ list. Items. Strings [list. itemindex] End; Procedure initializewizard (); Begin Mypage: = createcustompage (wpwelcome, 'title: Custom page', 'description: This is my custom page '); List: = tlistbox. Create (mypage ); List. Parent: = mypage. surface; List. Items. Add ('beijing '); List. Items. Add ('shanghai '); List. Items. Add ('Hong Kong '); List. Items. Add ('wuhan '); List. Items. Add ('guangzhou '); List. onclick: [email protected]; LBL: = tlabel. Create (mypage ); LBL. Parent: = mypage. surface; LBL. Top: = List. Top + list. height + 10; End; |
List. itemindex: return the index value of the selected item in the list box. Items. Strings [list. itemindex] indicates the string value of the item. The installation page is as follows:
In addition, the list box also has the multiselect option, indicating whether the list box supports multiple selections (press Ctrl when supported), but this performance is not very good, I personally think it is better to use multiple selection boxes at this time.