Skip to main content

ASPxClientListBox.GetSelectedItems Method

Returns an array of the list editor’s selected items.

Declaration

GetSelectedItems(): ASPxClientListEditItem[]

Returns

Type Description
ASPxClientListEditItem[]

An array of ASPxClientListEditItem objects that represent the selected items.

Remarks

Use the GetSelectedItems method to obtain an array of the selected items within a list box. A null value indicates that no item is currently selected within the list editor.

Note

The GetSelectedItems method is not in effect if the ASPxListBox.SelectionMode property is set to ListEditSelectionMode.Single value.

For more information about multiple selection, read the Multi-Selection Mode topic.

Example

The following section of the Moving Items Between Two List Boxes online demo illustrates how moving ASPxListBox items is implemented using the client ASPxClientListBox.GetSelectedItems, ASPxClientListBox.AddItem, ASPxClientListBox.RemoveItem, ASPxClientListBox.BeginUpdate and ASPxClientListBox.EndUpdate methods.

function AddSelectedItems() {
    MoveSelectedItems(lbAvailable, lbChoosen);
...
}

function RemoveSelectedItems() {
    MoveSelectedItems(lbChoosen, lbAvailable);
...
}
function MoveSelectedItems(srcListBox, dstListBox) {
    srcListBox.BeginUpdate();
    dstListBox.BeginUpdate();
    var items = srcListBox.GetSelectedItems();
    for(var i = items.length - 1; i >= 0; i = i - 1) {
        dstListBox.AddItem(items[i].text, items[i].value);
        srcListBox.RemoveItem(items[i].index);
    }
    srcListBox.EndUpdate();
    dstListBox.EndUpdate();
}
See Also