Shiny Language Reference

Language Reference > User Interface > List Boxes


getlistboxcursel

int getlistboxcursel(int ID);

 

Synonyms:

int getlistcursel(int ID);

int getlbcursel(int ID);

 

Retrieves the currently selected item index in a listbox

The GETLISTBOXCURSEL statement retrieves the index of the currently selected item in a list box.

 

Parameters

ID

The control ID of the control in which to retrieve the selection

 

Return Value

The zero based index of the selection

 

Example Code

// Create the edit box X: 10, Y:10 and sized 200*120
int iListBoxID = createlistbox(1, 10, 10, 200, 120);

// Add 25 test items
for(int iTest = 0; iTest < 25; iTest++)
    addlistboxitem(iListBoxID, "Test item " + iTest);


// Set the selection to item 10 (11th item)
setlistboxcursel(iListBoxID, 10);

// Retrieve the selection, will return 10
int iSel = getlistboxcursel(iListBoxID);