{"name":"lbSetCurSel","operator":null,"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","replaced_by":[],"games":[{"game":"ofp","name":"Operation Flashpoint","version":"1.75"},{"game":"ofpe","name":"Operation Flashpoint: Elite","version":"1.00"},{"game":"arma1","name":"Armed Assault","version":"1.00"},{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"ofp","name":"Operation Flashpoint","version":"1.75"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"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>\n> CT_COMBO does not allow deselecting entries, it will instead select the first one as it is not a combobox usual behaviour.\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]","since":null,"effect":null,"exec":null,"params":[{"name":"idc","type":"Number","optional":false,"default":null,"description":"control's IDC","types":["Number"],"since":null,"text":"idc: Number - control's IDC"},{"name":"index","type":"Number","optional":false,"default":null,"description":null,"types":["Number"],"since":null,"text":"index: Number"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"unary","operator":null,"left":null,"right":{"text":"[idc, index]","types":["Array"]}},{"syntax":"control lbSetCurSel index","since":null,"effect":null,"exec":null,"params":[{"name":"control","type":"Control","optional":false,"default":null,"description":null,"types":["Control"],"since":null,"text":"control: Control"},{"name":"index","type":"Number","optional":false,"default":null,"description":null,"types":["Number"],"since":null,"text":"index: Number"}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"binary","operator":null,"left":{"text":"control","types":["Control"]},"right":{"text":"index","types":["Number"]}}],"examples":[{"text":"```sqf\nlbSetCurSel [101, 0];\n```","code":["lbSetCurSel [101, 0];"]},{"text":"```sqf\n_control lbSetCurSel 0;\n```","code":["_control lbSetCurSel 0;"]}],"multiplayer":null,"problems":null,"aliases":[],"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."}],"categories":["ArmA: Armed Assault: Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: GUI Control - ListBox","Introduced with Operation Flashpoint version 1.75","Operation Flashpoint: Elite: Scripting Commands","Operation Flashpoint: New Scripting Commands","Operation Flashpoint: Scripting Commands","Scripting Commands","Take On Helicopters: Scripting Commands"]}