Micro Focus QTP (UFT) Forums
Get Item Property - 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 Item Property (/Thread-Get-Item-Property)



Get Item Property - saravananrd@gmail.com - 10-06-2009

Hi

Value displayed in combobox is LAB & RAD, but 0 and 1 is getting displayed in msgbox i

Code:
ICount  =  SwfWindow(" ").SwfComboBox("SwfComboBox").GetItemsCount
msgbox ICount (Output is 2)

For i  = 0 to ICount - 1
    SwfWindow(" ").SwfComboBox("SwfComboBox").GetItem (i)
    msgbox i (First Iternation 0 and Second Iternation 1)
Next



RE: Get Item Property - Saket - 10-06-2009

it is obvious. see, in your code you statement 'msgbox i' clearly says to get an output for values of your variable 'i'
and in the for loop i varies from 0 to 1.
so you are getting the values as 0 and 1.
I guess you are trying to get the selected item.
if yes then use GetSelection method.
e.g.
Code:
msgbox SwfWindow(" ").SwfComboBox("SwfComboBox").GetSelection



RE: Get Item Property - basanth27 - 10-06-2009

Use this piece of code,

Code:
ICount  =  SwfWindow(" ").SwfComboBox("SwfComboBox").GetItemsCount
msgbox ICount (Output is 2)

For i  = 0 to ICount - 1
itemname =swfWindow(" ").SwfComboBox"SwfComboBox").GetItem (i)
    msgbox itemname
Next

As saket pointed out you are only msgboxing i value then the retireved item value. You have to store it in a variable and then read from it.


RE: Get Item Property - saravananrd@gmail.com - 10-06-2009

Thanks Saket
I need only the values(LAB & RAD)in the combo box without selecting.
I am using getitem will retrun by index, so first time Lab and second time Rad.
Is my understanding right?


RE: Get Item Property - basanth27 - 10-06-2009

@Saket - GetSelection will retrieve the item which is selected ( I suspect if there is a getselection for a swfcombobox..not sure yet.). Getitem will retrieve each item available in the collection.


RE: Get Item Property - Saket - 10-06-2009

Yes,, you are right.
if you dont want to select the item then use a variable to get the value and output that variable, as suggested by Basanth.


RE: Get Item Property - saravananrd@gmail.com - 10-06-2009

Thanks Basanth & Saket
It works.