Jump to content

TreeView item children


chtom
 Share

Recommended Posts

Hi,

I'm new to Autoit and, so far, I managed to find all the information I needed.

Now, I try to use the Treeview component, with two levels of items in my tree hierarchy.

When the user selects a tree item I would like to do some action on its children. Actually, I am using a checkbox tree and I just want to check all the children of the selected item.

I searched the forum but I did not find any tip to get all the tree view items attached to another item.

How can I do this?

Thank you.

Chtom.

Link to comment
Share on other sites

Hi,

I'm new to Autoit and, so far, I managed to find all the information I needed.

Now, I try to use the Treeview component, with two levels of items in my tree hierarchy.

When the user selects a tree item I would like to do some action on its children. Actually, I am using a checkbox tree and I just want to check all the children of the selected item.

I searched the forum but I did not find any tip to get all the tree view items attached to another item.

How can I do this?

Thank you.

Chtom.

Look at the GuiTreeView Management section in the UDF Defined Functions in the Beta Help

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Look at the GuiTreeView Management section in the UDF Defined Functions in the Beta Help

could have done with this a while ago :) , ended up concocting my own version so I could dynamically create an active directory OU path from a tree structure:

CODE
#include <GUIConstants.au3>

#include <GuiTreeView.au3>

GUICreate( "tree", 400, 160)

$Tree = GUICtrlCreateTreeView ( 10, 10, 140, 140)

$treeRoot = GUICtrlCreateTreeViewItem ( "Root", $Tree )

$Treeitem1 = GUICtrlCreateTreeViewItem ( "Section 1", $TreeRoot )

$Treeitem1a = GUICtrlCreateTreeViewItem ( "item 1", $Treeitem1 )

$Treeitem1b = GUICtrlCreateTreeViewItem ( "item 2", $Treeitem1 )

$Treeitem2 = GUICtrlCreateTreeViewItem ( "Section 1", $TreeRoot )

$Treeitem2a = GUICtrlCreateTreeViewItem ( "item 1", $Treeitem2 )

$Treeitem2aa = GUICtrlCreateTreeViewItem ( "subitem 1", $Treeitem2a )

$TreepathDisplay = guictrlcreateinput ( "", 170, 50, 210, 25 )

GUISetState()

while 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = guictrlread ($Tree)

If GUICtrlRead($Tree, 1) <> "" Then

$Treeitem = GUICtrlRead($Tree, 1)

GUICtrlSetData ($TreepathDisplay, _Get_Treepath() )

EndIf

EndSelect

WEnd

Func _Get_Treepath()

If GUICtrlRead($Tree, 1) <> "Root" Then

$Treepath = GUICtrlRead ($Tree, 1) & ","

If GUICtrlRead ( _GUICtrlTreeViewGetParentID ($Tree), 1) <> "Root" Then

$Treepath &= GUICtrlRead ( _GUICtrlTreeViewGetParentID ($Tree), 1) & ","

If GUICtrlRead ( _GUICtrlTreeViewGetParentID ($Tree, _GUICtrlTreeViewGetParentHandle($Tree)), 1) <> "Root" Then

$parent = _GUICtrlTreeViewGetParentHandle($Tree)

While GUICtrlRead (_GUICtrlTreeViewGetParentID($Tree, $parent), 1) <> "Root"

$Treepath &= GUICtrlRead ( _GUICtrlTreeViewGetParentID ($Tree, $parent), 1) & ","

$parent = _GUICtrlTreeViewGetParentHandle($Tree, $parent)

WEnd

EndIf

EndIf

$Treepath &= "Root"

Else

$Treepath = GUICtrlRead ($treeRoot, 1)

EndIf

Return $Treepath

EndFunc ;==>_Get_Treepath

ah well.

"My God, you're looking hideously ugly today, Ugly Bob."

Link to comment
Share on other sites

Thanks for your answers.

I first tried the method used in the _GUICtrlTreeViewExpand method which goes through every children of a given item ( recursive calls to GUICtrlSendMsg($i_treeview, $TVM_GETNEXTITEM, $TVGN_CHILD, $h_item) etc.)

But as I needed to manipulate checkbox of tree view items which I had only the handle, my search brought me to the auto3lib, and all its method to manipulate tree views.

Even if the method _TreeView_SetChecked has a weird behavior (visually select an item to check it), everything works pretty well.

Bye.

Chtom

Link to comment
Share on other sites

Thanks for your answers.

I first tried the method used in the _GUICtrlTreeViewExpand method which goes through every children of a given item ( recursive calls to GUICtrlSendMsg($i_treeview, $TVM_GETNEXTITEM, $TVGN_CHILD, $h_item) etc.)

But as I needed to manipulate checkbox of tree view items which I had only the handle, my search brought me to the auto3lib, and all its method to manipulate tree views.

Even if the method _TreeView_SetChecked has a weird behavior (visually select an item to check it), everything works pretty well.

Bye.

Chtom

Might want to look at the latest beta GuiTreeView Management, all that is in the auto3lib should be in there also.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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...