Forum Discussion

jsayre's avatar
jsayre
Occasional Contributor
10 years ago
Solved

Working with ListView objects

I am doing some work on selected items from a list view but I need to identify an item and subitem within the selected collection. I attempted to use the subitem collection but when i define an item within that collection, it simply tells me "Wrong number of arguments or invalid property assignment.





// JScript Code

if (i=0;i<ListView.SelectedItems.Item(0).SubItems.Count;i++)

{

Log.Message(ListView.SelectedItems.Item(0).SubItems(i));

}

else

{

Log.Message("No Sub Items");

}





The above will properly return the SubItems.count (as 11) but when attempting to select and item from that collection, It returns an error. I have also attempted this with .text on the subitem as well to verify that I wasn't just returning anything unexpected.



My purose is to iterate through the subitems to make sure that they exist and are valid.



Any suggestions?
  • Hi Jeremy,

     


    Try to access the subitem in the following way:




    ListView.SelectedItems.Item(0).SubItems.Item(i)



2 Replies

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)
    Hi Jeremy,

     


    Try to access the subitem in the following way:




    ListView.SelectedItems.Item(0).SubItems.Item(i)



  • jsayre's avatar
    jsayre
    Occasional Contributor
    I could have sworn that I tried this method previously but it works now so I obviously overlooked it.



    Thank you Tanya