{"name":"lbSetCurSel","title":"lbSetCurSel","type":"command","url":"https://community.bistudio.com/wiki/lbSetCurSel","revid":376677,"updated":"2025-11-04T00:29:50Z","groups":["GUI Control - ListBox"],"status":"ok","games":{"ofp":"1.75","ofpe":"1.00","arma1":"1.00","arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"ofp 1.75","arma3_since":"0.50","description":"Selects the item with the given index in the listbox, listnbox, combobox, xcombobox, xlistbox\n\n> [!IMPORTANT]\n> **The following only applies to the Alternative Syntax when used with CT_LISTBOX and CT_LISTNBOX.**\n>\n> To deselect all entries, use -1: `_ctrl lbSetCurSel -1;` For listbox of style LB_MULTI use lbSetSelected instead.\n> CT_COMBO does not allow deselecting entries, it will instead select the first one as it is not a combobox usual behaviour.\n>\n> 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.","syntaxes":[{"syntax":"lbSetCurSel [idc, index]","params":[{"name":"idc","type":"Number","description":"control's IDC","type_expr":"Number"},{"name":"index","type":"Number","type_expr":"Number"}],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"unary","right":{"text":"[idc, index]"}},{"syntax":"control lbSetCurSel index","params":[{"name":"control","type":"Control","type_expr":"Control"},{"name":"index","type":"Number","type_expr":"Number"}],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"binary","left":{"text":"control"},"right":{"text":"index"}}],"examples":[{"code":["lbSetCurSel [101, 0];"]},{"code":["_control lbSetCurSel 0;"]}],"see_also":["lbCurSel"],"notes":[{"user":"DreadedEntity","date":"2014-11-29T23:40:00Z","text":"**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."},{"user":"Longbow","date":"2015-03-01T18:37:00Z","text":"Keep in mind that running this command will fire the 'onLBSelChanged' event handler."}]}