Page 1 of 1

TreeViewSelectItem

Posted: Mon Mar 26, 2007 7:26 pm
by tkondal
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.

Posted: Tue Mar 27, 2007 9:30 pm
by webops
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