Arma 3 Scripting

Command in GUI Control - ListBox

lbSetCurSel

Also available as Markdown and JSON, or read the original wiki page.

Description

Selects the item with the given index in the listbox, listnbox, combobox, xcombobox, xlistbox

Important

The following only applies to the Alternative Syntax when used with CT_LISTBOX and CT_LISTNBOX.

To deselect all entries, use -1: _ctrl lbSetCurSel -1; For listbox of style LB_MULTI use lbSetSelected instead.

CT_COMBO does not allow deselecting entries, it will instead select the first one as it is not a combobox usual behaviour. If you really need to deselect a combobox, see DreadedEntity's note. For the ComboBox you might as well want to explicitly select index 0 to avoid showing ghost row.

Syntax

Syntax 1

lbSetCurSel [idc, index]

Parameters:

Returns: Nothing

Syntax 2

control lbSetCurSel index

Parameters:

Returns: Nothing

Examples

Example 1

lbSetCurSel [101, 0];

Example 2

_control lbSetCurSel 0;

See also

lbCurSel

Community notes

DreadedEntity

Prior to ArmA 1.90 lbSetCurSel -1 had no effect while the listbox was populated. You needed to use lbClear first, then lbSetCurSel -1, then re-populate the listbox.

Longbow

Keep in mind that running this command will fire the 'onLBSelChanged' event handler.