{"name":"tvSetCurSel","title":"tvSetCurSel","type":"command","url":"https://community.bistudio.com/wiki/tvSetCurSel","revid":369062,"updated":"2024-09-02T20:24:55Z","groups":["GUI Control - Tree View"],"status":"ok","games":{"arma3":"0.74"},"since":"arma3 0.74","arma3_since":"0.74","description":"Sets cursor to given item on given path. IDC means id of parent Tree View. To deselect all items use [-1] for the path param (*available since Arma 3 v1.56*)","syntaxes":[{"syntax":"tvSetCurSel [idc, path]","params":[{"name":"idc","type":"Number","type_expr":"Number"},{"name":"path","type":"Array of Numbers","type_expr":"Array<Number>"}],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"unary","right":{"text":"[idc, path]"}},{"syntax":"control tvSetCurSel path","params":[{"name":"control","type":"Control","type_expr":"Control"},{"name":"path","type":"Array of Numbers","type_expr":"Array<Number>"}],"returns":{"type":"Nothing","type_expr":"Nothing"},"form":"binary","left":{"text":"control"},"right":{"text":"path"}}],"examples":[{"code":["tvSetCurSel [101, [0]];"]},{"code":["_ctrl tvSetCurSel [0,0,0];"]},{"text":"```sqf\n0 spawn\n{\n    disableSerialization;\n    _CT_TREE = findDisplay 46 ctrlCreate [\"RscTree\", -1];\n    _CT_TREE ctrlSetPosition [0,0,0.3,1];\n    _CT_TREE ctrlCommit 0;\n    _CT_TREE tvAdd [[],\"Parent_A\"];\n    _CT_TREE tvAdd [[0],\"Child_A\"];\n    _CT_TREE tvAdd [[0,0],\"Grandchild_A\"];\n    _CT_TREE tvAdd [[],\"Parent_B\"];\n    _CT_TREE tvAdd [[1],\"Child_B\"];\n    sleep 1;\n    hint \"SELECT [0,0,0]\";\n    _CT_TREE tvSetCurSel [0,0,0];\n    sleep 2;\n    hint \"DESELECT ALL\";\n    _CT_TREE tvSetCurSel [-1];\n};\n```","code":["0 spawn\n{\n\tdisableSerialization;\n\t_CT_TREE = findDisplay 46 ctrlCreate [\"RscTree\", -1];\n\t_CT_TREE ctrlSetPosition [0,0,0.3,1];\n\t_CT_TREE ctrlCommit 0;\n\t_CT_TREE tvAdd [[],\"Parent_A\"];\n\t_CT_TREE tvAdd [[0],\"Child_A\"];\n\t_CT_TREE tvAdd [[0,0],\"Grandchild_A\"];\n\t_CT_TREE tvAdd [[],\"Parent_B\"];\n\t_CT_TREE tvAdd [[1],\"Child_B\"];\n\tsleep 1;\n\thint \"SELECT [0,0,0]\";\n\t_CT_TREE tvSetCurSel [0,0,0];\n\tsleep 2;\n\thint \"DESELECT ALL\";\n\t_CT_TREE tvSetCurSel [-1];\n};"]}],"see_also":["tvAdd","tvClear","tvCollapse","tvCount","tvCurSel","tvData","tvDelete","tvExpand","tvPicture","tvSetData","tvSetPicture","tvSetValue","tvSort","tvSortByValue","tvText","tvValue"]}