TreeViewSelectItem

Class library usage, coding and language questions.
tkondal
Posts: 24
Joined: Fri Nov 03, 2006 5:50 pm

TreeViewSelectItem

Post by tkondal » Mon Mar 26, 2007 7:26 pm

Hi,

I am having trouble using the Ranorex.TreeViewSelectItem() function. I keep on getting an argument error in Python. I am passing it two arguments (a handle to my treeview and another handle to my treeview item).

Code: Select all

Ranorex.TreeViewSelectItem(hTreeView, hTreeViewRoot);
According to the docs, that's all that is needed, am I doing something wrong here? (By the way, both arguments are valid handles)

Thanks.

admin
Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Tue Mar 27, 2007 9:30 pm

The function TreeViewSelectItem has three arguments, the first one is the handle of the treeview, the second is the name of the item to select and the third one is the handle of the item to start the search from.
The Python documentation is not right, sorry, we will correct it for the next release.

Please see the usage in the sample TreeViewTest.py from the Samples directory.

The following code dumps out all items of the treeview:

Code: Select all

def checkItem(treeView,item):
    text = Ranorex.TreeViewGetItemText(treeView,item)
    print '    text=' + str(text)
    actItem = item
    while actItem >= 0 :
        subitem=Ranorex.TreeViewGetChildItem(treeView,actItem)
        if subitem > 0:
            checkItem(treeView, subitem)
        actItem = Ranorex.TreeViewGetNextItem(treeView,actItem)
        if actItem == 0:
            break
        text = Ranorex.TreeViewGetItemText(treeView,actItem)
        print '    text=' + str(text)
        cp = Ranorex.ControlGetPosition(treeView)
        Ranorex.TreeViewSelectItem(treeView,text)
        position = Ranorex.TreeViewGetItemPosition(treeView,actItem)
        print '    position=',
        print position
        if position != None:
            Ranorex.MouseMove(cp[0]+position[0]+(position[2]-position[0])/2,cp[1]+position[1]+10,10)

...
item = Ranorex.TreeViewGetRootItem(treeView)
text = Ranorex.TreeViewGetItemText(treeView,item)
print '  roottext=' + str(text)
checkItem(treeView, item)
...
item = Ranorex.TreeViewSelectItem(treeView,'SecondNode - SecondChild')
...
Jenö
Ranorex Team