Ranorex

Selecting Items in ListView control ?

 
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexPython
View previous topic :: View next topic  
Author Message
vonBrabant



Joined: 24 May 2007
Posts: 15

PostPosted: Thu May 24, 2007 11:50 pm    Post subject: Selecting Items in ListView control ?
Hi,

I'm just getting started with Ranorex and I have a problem with a ListView control whose items have no name.

I can get the number of items with ListViewGetItemCount(), but how can I select an item if it has no name? ListViewSelectItem() wants a name and not an item number Sad

vonBrabant
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 05 Jul 2006
Posts: 351

PostPosted: Fri May 25, 2007 12:24 am    Post subject:
You can use the Element functions, the element approach supports a general way for automating components, the following code dumps out and selects all elements of the list view in the VS2005Application:

Code: click into code to enlarge
print '--------------------------------------------------------------------'
print ' Searching and testing the list view'
print '--------------------------------------------------------------------- '
print '   searching the list view by control name'
listView=Ranorex.FormFindChildControlName(form,'listView1')
if listView == 0:
    print 'ERROR: listView not found'
    return 1       

print '      listView=' + hex(listView)
Ranorex.ControlSetFocus(listView)

print '      moving the mouse to the control'
Ranorex.MouseMoveToControl(listView)
element = Ranorex.ControlGetElement(listView)
if element == 0:
    print 'ERROR: listView element not found'
    return 1       

listElement = Ranorex.ElementFindChild(element, Ranorex.ROLE_SYSTEM_LIST)
if listElement == 0:
    print 'ERROR: list element not found'
    return 1       
   
# Dump out all list items
childCount = Ranorex.ElementGetChildCount(listElement);
for index in range(0,childCount):
    item = Ranorex.ElementGetChild(listElement,index)
    if item == None:
        break
    print '      Item = ' + Ranorex.ElementGetName(item)
    Ranorex.ElementSelect(item, Ranorex.SELFLAG_TAKEFOCUS | Ranorex.SELFLAG_TAKESELECTION);

Jenö
Ranorex Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexPython All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum