mikkol 11 Posted May 9, 2015 (edited) Hey! Can somebody help me with getting data from listbox to another listbox? I cheked this older thread, but it isnt exactly what i'm looking for. Or i dont know how to use those codes :D http://forums.bistudio.com/showthread.php?184556-How-to-return-data-of-selected-listbox-lbCurSel-returns-number What i'm trying to do is get group from first listbox and get group leader name to second listbox. In first listbox i have all groups //Grouplist box disableSerialization; waitUntil {!isNull (findDisplay 1734)}; lbClear 1500; _friendlyside = side player; { if ((side _x) == _friendlyside) then { _groupname= groupid _x; _GrouplistDialog = (findDisplay 1734) displayCtrl 1500; _addThisToListBox = _groupname; _GrouplistDialog lbAdd _addThisToListBox; }; } forEach allgroups; So First listbox works but in second listbox i got error "Type string, expected object". Second listbox //Second listbox disableSerialization; lbClear 1600; _index = lbCurSel 1500; _text = lbText [1500, _index]; lbSetData [1500, _index, _text]; _data = lbData [1500, _index]; //How do i get actual group, not STRING _Group = Group _data; _Leader = (Leader _Group); player sideChat format ["%1",_Leader]; _GrouplistDialog = (findDisplay 1734) displayCtrl 1600; _addThisToListBox = _Group; _GrouplistDialog lbAdd _addThisToListBox; obviously Second listbox dont work. So i need to get the actual "group" not "String" of group :) Edited May 9, 2015 by MikkoL Share this post Link to post Share on other sites
dreadedentity 278 Posted May 9, 2015 BIS_fnc_objectVar might be useful to you Share this post Link to post Share on other sites
mikkol 11 Posted May 9, 2015 Where i should call "BIS_fnc_objectVar" ? every variation i tried ended with "Type string, expected object". Share this post Link to post Share on other sites
killzone_kid 1333 Posted May 9, 2015 You can try netId and groupFromNetId in MP Share this post Link to post Share on other sites
mikkol 11 Posted May 9, 2015 (edited) Thanks DreadedEntity and Killzone_Kid. I got it working with "KK_fnc_netId" & "KK_fnc_objectFromNetId" and "cases". _index = lbCurSel 1500; switch (_index) do { case 0: { _getNetId = "0:1" call KK_fnc_objectFromNetId; _Group = Group _getNetId; _Leader = (Leader _Group); _Name = Name _Leader; player sidechat format ["%1",_Name]; _GrouplistDialog = (findDisplay 1734) displayCtrl 1600; _addThisToListBox = _Name; _GrouplistDialog lbAdd _addThisToListBox; }; case 1: { _getNetId = "0:2" call KK_fnc_objectFromNetId; _Group = Group _getNetId; _Leader = (Leader _Group); _Name = Name _Leader; player sidechat format ["%1",_Name]; _GrouplistDialog = (findDisplay 1734) displayCtrl 1600; _addThisToListBox = _Name; _GrouplistDialog lbAdd _addThisToListBox; }; }; Next step is try to get this working "dynamically" so that I wouldn't have to create "case" to every group. Edited May 9, 2015 by MikkoL Share this post Link to post Share on other sites
Larrow 2828 Posted May 9, 2015 (edited) Are you just trying to create two list boxes that are relevant to each other? e.g like a table that shows a list of group names and next to each one its leader? Im slightly confused by your use of lbCurSel and what its purpose is in your setup. If your just trying to create a table of groupname - leader it should be a simple as..... //IDD and IDC of UI elements _GrpDisplay_IDD = 1734; _GrpNameLB_IDC = 1500; _GrpLeaderLB_IDC = 1600; disableSerialization; waitUntil {!isNull (findDisplay _GrpDisplay_IDD)}; //Clear the listboxes lbClear _GrpNameLB_IDC; lbClear _GrpLeaderLB_IDC; { if ( (side _x) isEqualTo side player ) then { //Add group ID to first listbox lbAdd [ _GrpNameLB_IDC, ( groupID _x ) ]; //Add leader ID to second listbox _index = lbAdd [ _GrpLeaderLB_IDC, str ( leader _x ) ]; //Store leaders var is second listbox data lbSetData [ _GrpLeaderLB_IDC, _index, ( leader _x ) call BIS_fnc_objectVar ]; }; } forEach allgroups; If this is what your trying to do it may be worth looking into RscListNBox. Which is just a listbox with multiple columns and would save you headaches with syncing scrolling and selections between multiple listboxes. To get the group back out of the above you would do something like.. fnc_getLBGroup = { //IDCs _GrpNameLB_IDC = 1500; _GrpLeaderLB_IDC = 1600; //Get currently selected group _index = lbCurSel _GrpNameLB_IDC; //Get relative leader var from leader listbox data _leaderVar = lbData [ _GrpLeaderLB_IDC, _index ]; //Get leaders group _group = group ( missionNamespace getVariable _leaderVar ); //Return the group _group }; Edited May 9, 2015 by Larrow Share this post Link to post Share on other sites
mikkol 11 Posted May 9, 2015 (edited) Yeah! Two boxes relevant to each other. This is my first gui stuff with arma , so maybe my code is confusing :). With "lbCurSel" i mean "selected group in grouplist box". Thanks Larrow for help! gonna test your code. Added pics to explain what im trying to do. Edited May 9, 2015 by MikkoL Share this post Link to post Share on other sites
killzone_kid 1333 Posted May 9, 2015 MikkoL said: Thanks DreadedEntity and Killzone_Kid.I got it working with "KK_fnc_netId" & "KK_fnc_objectFromNetId" and "cases". If you want to use my functions you need to use KK_fnc_groupFromNetId for groups: https://community.bistudio.com/wiki/groupFromNetId Share this post Link to post Share on other sites
mikkol 11 Posted May 9, 2015 ok! Atleast for testing purpose im using your function. I changed to kk_fnc_groupfromnetid. Share this post Link to post Share on other sites