Syntax 2 For PictureListBox and DropDownPictureListBox controls
Description
Adds a new item to the list of values in a picture list box.
Controls
PictureListBox and DropDownPictureListBox controls
Syntax
|
1 |
<span>listboxname</span>.<span>AddItem</span> ( <span>item</span> {, <span>pictureindex</span> } ) |
|
Argument |
Description |
|---|---|
|
listboxname |
The name of the PictureListBox or DropDownPictureListBox |
|
item |
A string whose value is the text of the |
|
pictureindex (optional) |
An integer specifying |
Return Values
Integer. Returns the position of the
new item. If the list is sorted, the position returned is the position
of the item after the list is sorted. Returns -1 if it fails. If
any argument’s value is null, AddItem returns null.
Usage
If you do not specify a picture index, the newly added item
will not have a picture.
If you specify a picture index that does not exist, that number
is still stored with the picture. If you add pictures to the picture
array so that the index becomes valid, the item will then show the
corresponding picture.
For additional notes about items in list boxes,
see Syntax 1.
Examples
This example adds the item Cardinal to the PictureListBox plb_birds:
|
1 |
integer li_pic, li_position |
|
1 |
string ls_name, ls_pic |
|
1 |
|
1 |
li_pic = plb_birds.AddPicture("c:picscardinal.bmp") |
|
1 |
ls_name = "Cardinal" |
|
1 |
li_position = plb_birds.<span>AddItem</span>(ls_name, li_pic) |
If plb_birds contains Robin
and Swallow and the Sorted property is false,
the AddItem function above returns 3 because
Cardinal becomes the third and last item. If the Sorted property
is true, AddItem returns 1
because Cardinal is first when the list is sorted alphabetically.