Micro Focus QTP (UFT) Forums
Get value of a List view item - 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: Get value of a List view item (/Thread-Get-value-of-a-List-view-item)



Get value of a List view item - qtpbegin - 07-19-2012

How to get a value from a List view.

For me x = SwfWindow("Connected to 157.235.206.175").SwfListView("inventoryList").GetVisibleText is showing the entire value in the listview.
My List view has 10 columns and 5 rows.

I need the value of the third column in second row.
How I can get it.
Please help me.


RE: Get value of a List view item - sree.85 - 07-19-2012

The Below program might solve your problem
a brief explanation of the below program

1) get total no of columns --------->(ColumnCount)
2) get total no rows in the wilnlist view------->(GetItemsCount)
3) retrieve the desired value from the column------>(GetSubItem(i,C_Name))


Code:
With Dialog("Text:=Windows Task Manager")
    .wintab("nativeclass:=SysTabControl32").Select "Processes"
    
R_Count=.WinListView("nativeclass:=SysListView32").GetItemsCount
'msgbox ("Total no of rows"&R_Count)

C_Count=.WinListView("nativeclass:=SysListView32").ColumnCount
'msgbox ("Total no of columns:  "&C_Count)

For i=0 to R_Count-1
    For j=0 to C_Count-1
        C_Name=.WinListView("nativeclass:=SysListView32").GetColumnHeader(j)
        t= .WinListView("nativeclass:=SysListView32").GetSubItem(i,C_Name)
        
    Next
Next
End With

i hope the above program will help you


RE: Get value of a List view item - qtpbegin - 07-20-2012

Thanks sree.....
Everything works for me except two line
1)stView_ChildObjects")=t
2)Endwith

Can I store the values of C_name and t in a two diamensional array in QTP?


RE: Get value of a List view item - sree.85 - 07-26-2012

the above two lines are not required for u. you can comment those lines...

"C_name" it the name of the coloumn and t is the values in the column like
C_name
--------
aaaa
bbbb
cccc

so you can't take the data into a two dimensional array
but u can load the data into a data table or to an excel sheet


RE: Get value of a List view item - Deepak_QTP - 08-08-2012

Hi Sree,

Thanks a lot for this post.

Regards,
Deepak