Using drop-down lists
Drop-down lists are
another way to present simple lists of information to the user.
You can present your lists with just text (in a DropDownListBox)
or with text and pictures (in a DropDownPictureListBox). You add
DropDownListBox and DropDownPictureListBox controls to windows in
the same way you add other controls: select DropDownListBox or DropDownPictureListBox
from the Insert>Control menu and click the window.
Adding items to drop-down list controls
In the painter Use the Items property page for the control to add items.
To add items to a DropDownListBox or DropDownPictureListBox:
-
Select the Items tab in the Properties
view for the control. -
Enter the name of the items for the ListBox. For
a PictureListBox, also enter a picture index number to associate
the item with a picture.For how to add pictures to a DropDownPictureListBox,
see “Adding pictures to DropDownPicture
ListBox
controls”.
In a script Use the AddItem and InsertItem functions
to dynamically add items to a DropDownListBox or DropDownPictureListBox
at runtime.
AddItem adds items to the end of the list.
However, if the list is sorted, the item will then be moved to its
position in the sort order. Use InsertItem if
you want to specify where in the list the item will be inserted.
Function | You supply |
---|---|
InsertItem |
|
AddItem |
|
This example inserts three items into a DropDownPictureListBox
in the first, second, and third positions:
1 |
This.InsertItem ("Atropos", 2, 1)<br />This.InsertItem ("Clotho", 2, 2)<br />This.InsertItem ("Lachesis", 2, 3) |
This example adds two items to a DropDownPictureListBox:
1 |
this.AddItem ("Plasma", 2)<br />this.AddItem ("Platelet", 2) |
Using the Sort property You can set the control’s sort property to TRUE to
ensure that the items in the list are always arranged in ascending
sort order.
Adding pictures to DropDownPicture
ListBox
controls
In the painter Use the Pictures and Items property pages for the control
to add pictures.
To add pictures to a DropDownPictureListBox:
-
Select the Pictures tab in the Properties
view for the control. -
Select an image from the stock image list, or
use the Browse button to select a bitmap, cursor, or icon image. -
Select a color from the PictureMaskColor drop-down
menu for the image.The color selected for the picture mask will appear transparent
in the DropDownPictureListBox. -
Select a picture height and width for your image.
This will control the size of the image in the DropDownPictureListBox.
Dynamically changing image size The image size can be changed at runtime by setting the PictureHeight
and PictureWidth properties before you add any pictures when you
create a DropDownPictureListBox. For more information about PictureHeight
and PictureWidth, see the PowerScript Reference. -
Repeat the procedure for the number of images
you plan to use in your DropDownPictureListBox. -
Select the Items tab and change the Picture Index
for each item to the appropriate number.
In a script Use the AddPicture function to dynamically
add pictures to a PictureListBox at runtime. For instance, this
example adds two BMP files to the PictureListBox:
1 |
This.AddPicture ("c:imagesjustify.bmp")<br />This.AddPicture ("c:imagescenter.bmp") |
Deleting pictures from DropDownPicture
ListBox
controls
For instructions on deleting pictures from DropDownPictureListBox
controls, see “Deleting pictures from picture
list controls”.