Forum Discussion

nika912's avatar
nika912
New Contributor
8 years ago
Solved

List view items

Hi everyone,

 

I'm new to TestComplete and i'm having problems with list view control. I am using TestComplete to test .NET based application.

 

Issue:

 

I'm trying to find a specific item in list view control and I was helping with the example on this link: https://support.smartbear.com/viewarticle/24752/

 

--

 

Function checkValueExists(listView, value)
Dim i, j
For i = 0 To listView.Columns.Count - 1
For j = 0 To listView.Items.Count - 1
If listView.Items(j,i) = value Then
checkValueExists = True
Exit Function
End If
Next
Next
checkValueExists = False
End Function

 

---

When using this function it gives back an error:

 

Wrong number of arguments or invalid property assignment: 'listView.Items' 

--
 
 

 

  • The example provided is using extended properties of the listview item and your code is not.

    The error message you are receiving is correct.

     

    You need to trace it to the line of code that is generating the error and verify that you are passing the correct number of parameters to the property or method.

     

    More than likely this is incorrect:

     

    If listView.Items(j,i) = value Then

     

    Try using the object spy to verify the number of parameters accepted by listView.Items (and that it is actually the property you want to check).

5 Replies

  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor

    The example provided is using extended properties of the listview item and your code is not.

    The error message you are receiving is correct.

     

    You need to trace it to the line of code that is generating the error and verify that you are passing the correct number of parameters to the property or method.

     

    More than likely this is incorrect:

     

    If listView.Items(j,i) = value Then

     

    Try using the object spy to verify the number of parameters accepted by listView.Items (and that it is actually the property you want to check).

    • nika912's avatar
      nika912
      New Contributor

      Hi, 

       

      I decided to try something else - my goal is to print entire listView.

       

      I've tried almost everything to just print at least one of the element in listView, but nothing seems to work, 

       

      I tried using spy to verify the number of parameters accepted by listView.Items, but I guess i'm doing something wrong.

       

      For example: calling method listView.Items.Count and listView.Colums.Count is working OK. So how can I print an item (I want to get string in log message or in a .txt file) in a specific row and column?

       

       

       

      • Colin_McCrae's avatar
        Colin_McCrae
        Community Hero

        The example you linked to is a Delphi one.

         

        You mentioned your control is a .NET one.

         

        They may well not have the same properties. (And Delphi also has numerous different types of Listview/Dropdown control types which all behave slightly differently)

         

        What's the class of the control you're trying to get the list items from?