Micro Focus QTP (UFT) Forums
How to handle WinListView object with multi line items? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: How to handle WinListView object with multi line items? (/Thread-How-to-handle-WinListView-object-with-multi-line-items)



How to handle WinListView object with multi line items? - jim7020 - 06-10-2008

I am writing a script for an application written in C++. I have a WinListView object with 18 columns that I need to be able to select an item by double clicking. Object Spy displays <muli-line value> for all items and selection. I recorded the action to see how QTP would recognize it and this is what I got:

Code:
Window("Workforce Management").Window("R&D").WinListView("Jobs").Select "H: 303-555-1212" + vbLf + "B: 303-555-1212"

Window("Workforce Management").Window("R&D").WinListView("Jobs").SetItemState "H: 303-555-1212

Window("(10000103399710680001)]").WinButton("OK").Click
Window("Workforce Management").Activate
B: 303-555-1212", micDblClick


It wont play back due the unterminated string for the SetItemState method. If you look at the last line above, the micDblClick should be on the same line as the SetItemState. When I try to manually script the line it doesnt recognize it:

Code:
Window("Workforce Management").Window("R&D").WinListView("Jobs").SetItemState "H: 303-555-1212" + vbLf + "B: 303-555-1212", micDblClick



RE: How to handle WinListView object with multi line items? - jim7020 - 06-11-2008

I wrote a loop to to put the values in "all items" in the WinListView object above into an array and then loop through and compare to a parameter in the datatable. The loop works correctly for the value in the first row but then next time it loops through i get: Subscript out of range: 'p'

Can anyone help me with this? Here is my code-

Code:
Get number of Rows (for Loop) and  Info
TECH_ROWS = window("Workforce Management").Window("R&D").WinListView("Techs").GetROProperty ("items count")
TECH_ITEMS = window("Workforce Management").Window("R&D").WinListView("Techs").GetROProperty ("all items")

'Split  Tech Info in to an Array
TECH_SPLIT = split(TECH_ITEMS, "All ")
TECH_INFO = split(TECH_SPLIT(0), "None Selected")

'Loop a MSGBOX for every Array value
For p = 0 to TECH_ROWS -1
        msgbox "Tech Found on Row " & p +1 & " is: " & Trim(TECH_INFO(p))
        
        'Job matching from Datasheet and values in Array
        If TechID = Trim(TECH_INFO(p)) Then
                msgbox "Tech = " & TechID & vbCr & "Row Found on Screen = " & Trim(TECH_INFO(p))
        End If
Next