Connection Information

To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

Connection Type

Using listboxes – PB Docs 70 – PowerBuilder Library

Using listboxes – PB Docs 70

Using listboxes

You can use listboxes to present information to the user in
simple lists with scrollbars. You can present this information with
text and pictures (in a PictureListBox) or with text alone (using
a ListBox).

Depending on how you design your application, the user can
select one or more list items to perform an action based on the
listbox selection.

You add ListBox and PictureListBox controls to windows in
the same way you add other controls: select ListBox or PictureListBox
from the Insert>Control menu and click the window.

Adding items to listbox controls

In the painter Use the Item property page for the control to add new items.

proc.gif To add items to a ListBox or PictureListBox:

  1. Select the Items tab in the Properties
    view for the control.

  2. 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 instructions on adding pictures to a PictureListBox,
    see “Adding pictures to PictureListBox controls”.

In a script Use the AddItem and InsertItem functions to dynamically add items
to a ListBox or PictureListBox at execution time. 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 Item namePosition in which the item will be insertedPicture index (for a PictureListBox)
AddItem Item namePicture index (for a PictureListBox)

For example, this script adds items to a ListBox:

This script adds items and images to a PictureListBox:

note.gif Using the Sort property You can set the control’s sort property to TRUE or
check the Sorted checkbox on the General property page to ensure
that the items in the list are always arranged in ascending alphabetical
order.

Adding pictures to PictureListBox controls

In the painter Use the Pictures and Items property pages for the control
to add pictures.

proc.gif To add pictures to a PictureListBox:

  1. Select the Pictures tab in the Properties
    view for the control.

  2. Select an image from the stock image list.

    or

    Use the Browse button to select a bitmap, cursor, or
    icon image.

  3. Select a color from the PictureMaskColor dropdown
    menu for the image.

    The color selected for the picture mask will appear transparent
    in the PictureListBox.

  4. Select a picture height and width.

    This will control the size of the images in the PictureListBox.

    note.gif Dynamically changing image size You can use a script to change the image size at execution
    time by setting the PictureHeight and PictureWidth properties before
    you add any pictures when you create a PictureListBox.

    For more information about PictureHeight and
    PictureWidth, see the PowerScript Reference.

  5. Repeat the procedure for the number of images
    you plan to use in your PictureListBox.

  6. 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 execution time. For example, the script below
sets the size of the picture, adds a BMP file to the PictureListBox,
and adds an item to the control:

Deleting pictures from picture
listbox controls

Use the DeletePicture and DeletePictures functions to delete
pictures from either a PictureListBox or a DropDownPictureListBox.

When you use the DeletePicture function, you must supply the
picture index of the picture you want to delete.

For example:

deletes the first Picture form the control, and

deletes all the pictures in a control.

Example The following window contains a ListBox control and a PictureListBox.
The ListBox control contains four items, and the PictureListBox
has one:

Uilst01.gif

When the user double-clicks an item in the ListBox, a script
executes to:

  • Delete all the items
    in the PictureListBox
  • Add new items to the PictureListBox that are related
    to the ListBox item that was double-clicked

Uilst02.gif

This is the script used in the ListBox DoubleClicked event:


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x