Selecting Combo Box items that are out of view
So in several of our applications we have combo boxes that contain large number of items (like over 100). Now TestComplete in some cases cannot select items that are out of view. I understand that it is out view, but is there any way I can bring focus to that item and select it. Is there any other workaround?
I have two code snippets that I tried:
for each item in sItemList
if Trim(item)=Trim(sEnterValue) Then
oObj.ClickItem(x)
Delay(1000)
exit for
End if
x = x + 1
Next
in the code above I extract the item list from the wItemList property and the seperator (wListSepreator property), and loop through the list. If I find the required value (sEnterValue variable) then I click it. This works perfectly for items IN VIEW.oObj is the comboBox object.
iItemCount = oObj.Items.Count
for x = 0 To iItemCount - 1
If Trim(LCase(oObj.Items.get_Item(x).OleValue))=Trim(LCase(sEnterValue)) Then
'oObj.Items.Refresh
oObj.ClickItem(oObj.Items.get_Item(x))
Delay(1000)
Exit for
End If
Next
In this second code snippet, I am trying to get the item directly using the get_Item property. It seems to work for items in view as well as for a few items out of view, but definelty NOT for items that are say 100+ down the list.
I see there is a navigatetoItem function as well as a set focus function for the combo box object. I am not sure what to pass in for those functions. I tried looking around the MSDN library but couldnt follow the liuterature there. My final solution would be to use the send keys. But, I would rather use that as a very last resort!!
We have a .Net application so the objects are of System.Windows.Controls classes.
We also tried record and replay, but still the item couldnt be selected.