Shoutbox

GetCurSel and SetCurSel with ListViewControl... - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: GetCurSel and SetCurSel with ListViewControl... (/showthread.php?tid=76841)

GetCurSel and SetCurSel with ListViewControl... by roflmao456 on 08-17-2007 at 07:25 PM

is there any function for this? i know there is one for the ListBox control but it doesn't seem to go with the ListView control :P it always returns 0


RE: GetCurSel and SetCurSel with ListViewControl... by matty on 08-18-2007 at 12:35 AM

code:
for (var i=0; pPlusWnd.LstView_GetCount('MyListView')-1; i++) {
    Debug.Trace(pPlusWnd.ListView_GetSelectedState('MyListView', i));
}

RE: GetCurSel and SetCurSel with ListViewControl... by markee on 08-18-2007 at 12:40 AM

Because a LstView Control can have many selected at a time you will have to iterate through the options.  You actually check a single item rather than checking for which element is selected.  You can do something like the following code though....

code:
[...]
var SelectedState = new Array();
var count = PlusWnd.LstView_GetCount("ControlId");
for(i=0;i<count;i++){
    SelectedState[i] = PlusWnd.LstView_GetSelectedState("ControlId",i);
}
[...]


If you have your XML set so that you can only have one selected however just try this....

code:
[...]
var count = PlusWnd.LstView_GetCount("ControlId");
for(i=0;i<count;i++){
    if(PlusWnd.LstView_GetSelectedState("ControlId",i)){
        var selected = i;
        break;
    }
}

As for setting one you just have to do it in much the same way as the ListBox except you need to put in the extra boolean variable for selecting or deselecting.

RE: GetCurSel and SetCurSel with ListViewControl... by roflmao456 on 08-18-2007 at 02:40 AM

that worked perfectly, thanks! (Y)(Y)