Jump to content

Select an item from treeView using index


Recommended Posts

Hi,

I just want to select an item from a treeview. I tried the following : 

 $selectedItem = ControlTreeView($wndHandle, "", "[NAME:tree]", "GetText", "#1") ; this for selecting the first item.

Sample tree view is attached with this. Could you please help me?

post-85609-0-98934000-1398180665.png

Link to comment
Share on other sites

Try using the below examples.

#include <GuiTreeView.au3>
$hTreeView = ControlGetHandle($GUIhandle, "", "[CLASS:SysTreeView32; INSTANCE:4]") ; The class for tree. Before that get the GUI handle
$hTMP = _GUICtrlTreeView_FindItem($hTreeView, $Treename, True) ; $treename = tree name if the main tree has a name.
If $hTMP Then
        _GUICtrlTreeView_Expand($hTreeView,$hTMP, True)
        Sleep(1000)
        $ret = _GUICtrlTreeView_GetText($hTreeView, $Treename)
Endif
If _GUICtrlTreeView_GetChildren($hTreeView, $hTMP) Then
       $hchild = _GUICtrlTreeView_GetFirstChild($hroot, $hparent)
       while $hchild
            $cText = _GUICtrlTreeView_GetText($hroot, $hchild)
            ;Do whatever you want
            $hchild = _GUICtrlTreeView_GetNextChild($hroot, $hchild)
        WEnd
Endif

Note: This is not a complete code. This is just an example

Edited by hellovivz
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...