ListBoxAddItem("ObjectLabel","Parameters")
|
|
Description
|
|
Add item(s) to a ListBox.
Possible parameters:
simple text (e.g. bla-bla-bla)
string variable (e.g. text$)
string array (e.g. text[n]$)
string separated by separator (e.g. str$='item1#item2#item3#')
text file (e.g. c:\Documents\testfile.txt)
<List> to insert internal lists
playlist MMB(*.m3l) and WinAmp playlists(*.pls, *.m3u) - (e.g. <SrcDir>\mix.m3u)
RESET to clear listbox content
RANDOMIZE parameter to randomize the listbox content is no longer used in MMB 4.9.5. Use the below ListBoxSort function to randomize or sort the ListBox contents.
|
|
Code Example
|
|
This small example will show the OpenFile dialog (with predefined mask) and after selection will load the selected playlist to the ListBox:
OpenFile("Play Lists(*.m3l;*.m3u;*.pls)|*.m3l;*.m3u;*.pls|All Files|*.*||","*.m3l;*.m3u;*.pls")
ListBoxAddItem("SongList","RESET")
ListBoxAddItem("SongList","OpenFile$")
String variable separated by a separator:
str$= 'item 4#item 5#item 6#'
ListBoxAddItem("ListBox1","str$,#")
For more examples check the ListBox_tut.mbd.
|
|
Additional Info
|
|
If you want to add a string containing the filename with extension use STRING: word in front of the filename string...
filename$='STRING:'+ExtractName(Path$)+ExtractExt(Path$)
ListBoxAddItem("ListBox","filename$")
|
|
ListBoxDeleteItem("ObjectLabel","ItemNum")
|
|
Description
|
|
Delete a given item from a ListBox. To delete all items use -1 as a parameter
Note: The the first item in the ListBox is always 1.
|
|
Code Example
|
|
The following example will delete the item #5 from the ListBox:
ListBoxDeleteItem("ListBox"," 5")
Here is an advanced example of ListBoxDeleteItem action. It will delete the selected item(s) from the ListBox after pressing Delete key:
| • | Create a new Script object and specify the keyboard shortcut to DELETE key. |
| • | Insert the below code to the Script section: |
ListBoxGetSelectedItems("ListBox","SelItemsArray$,NumSelItemsArray$,#,NumOfSelItems")
For i=NumItems To 1
numitem$ = GetArrayItem(NumSelItemsArray$,#,i)
numitem = VAL(numitem$)
ListBoxDeleteItem("ListBox","numitem")
Next i
|
|
ListBoxSortItems("ObjectLabel","Parameters")
|
|
Description
|
|
Function for randomizing and sorting the ListBox contents. Possible parameters:
NAME - sort items by name
TIME - sort items by time
VALUE - sort items by (integer) value
REVERSE - reverse current state
RANDOMIZE- randomize ListBox
|
|
Code Example
|
|
This simple example sorts the ListBox contents according the NAME of items
ListBoxSortItems("ListBox","NAME")
For example these items:
12 test
11 test
1 test
32 test
9 test
...sorted by NAME:
1 test
11 test
12 test
32 test
9 test
...but sorted by VALUE:
1 test
9 test
11 test
12 test
32 test
|
|
ListBoxSelectItem("ObjectLabel","ItemNum")
|
|
Description
|
|
Select a given item in a ListBox. To select all items use -1 as a parameter.
|
|
Code Example
|
|
The following example will select the item # 5 in the ListBox:
ListBoxSelectItem("ListBox"," 5")
|
|
ListBoxDeselectItem("ObjectLabel","ItemNum")
|
|
Description
|
|
Deselect a given item. To deselect all items use -1 as parameter
|
|
Code Example
|
|
The following example will deselect all items in the ListBox:
ListBoxDeselectItem("ListBox"," -1")
|
|
ListBoxMoveItem("ObjectLabel","ItemNum")
|
|
Description
|
|
Move selected item to position specified in Parameters field.
|
|
Code Example
|
|
The following example will move selected item UP.
ListBoxGetSelectedItems("ListBox","SelItems$,SelItemsNum$,#,AllNumItems")
For j=1 To AllNumItems
SelItem$ = GetArrayItem(SelItems$,#,j)
SelNum$ = GetArrayItem(SelItemsNum$,#,j)
SelNum = VAL(SelNum$)
Next j
If (SelNum>1) Then
ListBoxMoveItem("ListBox","SelNum-1")
End
The next example will move selected item DOWN.
ListBoxGetItems("ListBox","ItemsArray$,NumItemsArray$,#,NumOfAllItems")
ListBoxGetSelectedItems("ListBox","SelItems$,SelItemsNum$,#,AllNumItems")
For j=1 To AllNumItems
SelItem$ = GetArrayItem(SelItems$,#,j)
SelNum$ = GetArrayItem(SelItemsNum$,#,j)
SelNum = VAL(SelNum$)
Next j
If (SelNum<NumOfAllItems) Then
ListBoxMoveItem("ListBox","SelNum+1")
End
|
|
Additional Info
|
|
Limitation: Multiple selected items cannot be moved!
For more information check move_up_down.mbd example file.
|
|
ListBoxGetItems("ObjectLabel","Parameters")
|
|
Description
|
|
Retrieves all items from ListBox object. The first parameter must be string variable which contains items delimited by user defined delimiter. The second parameter must be also string variable which contains items indexes separated by delimiter too. The third parameter defines delimiter. The fourth parameter is a numeric variable, which contains number of all items in ListBox
|
|
Code Example
|
|
The following example return items from the ListBox:
ListBoxGetItems("ListBox","ItemsArray$,NumItemsArray$,#,NumOfAllItems")
For i=1 To NumOfAllItems
GetItem$ = GetArrayItem(ItemsArray$,#,i)
Message("ListBox Item...","GetItem$")
Next i
|
|
Additional Info
|
|
ListBoxGetItems can not only retrieve items from ListBox, but it can also feed the internal SongList with the ListBox items. Just use <List> constant as a second parameter of ListBoxGetItems function instead of usual ListBoxGetItems parameters.
Use this script for feeding the internal SongList <List> with the ListBox contents:
ListBoxGetItems("SongList","<List>")
|
|
ListBoxGetSelectedItems("ObjectLabel","Parameters")
|
|
Description
|
|
Retrieves selected items from ListBox object. The first parameter must be string variable which contains items delimited by user defined delimiter. The second parameter must be also string variable, which contains items indexes separated by delimiter too. The third parameter defines delimiter. The fourth parameter is a numeric variable, which contains number of selected items.
|
|
Code Example
|
|
The following example returns selected items in ListBox:
ListBoxGetSelectedItems("ListBox","SelItemsArray$,NumSelItemsArray$,#,NumOfSelItems")
For i=1 To NumOfSelItems
SelItem$ = GetArrayItem(SelItemsArray$,#,i)
Message("Selected Item...","SelItem$")
Next i
|
|
|
|
ListBoxParam("ObjectLabel","Parameters")
|
|
Description
|
|
Changes some of ListBox parameters defined in design-time in a run-time.
DRAG&DROP=ON/OFF - turns drag&drop on/off
NUMBERS=ON/OFF - show/hide item numbers
TIMES=ON/OFF - show/hide item times (only supported Audio/Video files)
BACKGROUND=R,G,B - sets background color
TEXT=R,G,B - set text color
IDTAGS=ON/OFF - search for (audio) IDtags when is ON.
|
|
Code Example
|
|
The below examples shows you how to change some of ListBox parameters:
ListBoxParam("ListBox","DRAG&DROP = ON")
ListBoxParam("ListBox","NUMBERS = OFF")
ListBoxParam("ListBox","TIMES = ON")
ListBoxParam("ListBox","BACKGROUND = 128,128,128")
ListBoxParam("ListBox","TEXT = 128,0,0")
ListBoxParam("ListBox","IDTAGS = OFF")
|
|
|