Sign in to follow this  
Followers 0
gcue

treeview: trying to expand just one parent

11 posts in this topic

Im able to expand the whole treeview but i want to just expand ONE parent..

ive tried using ($parent = the @ctrlid)

_GUICtrlTreeView_Expand($treeview, $parent, True)

Share this post


Link to post
Share on other sites



Im able to expand the whole treeview but i want to just expand ONE parent..

ive tried using ($parent = the @ctrlid)

_GUICtrlTreeView_Expand($treeview, $parent, True)

There is nothing wrong with the code you posted, so the problem is elsewhere. This is the help file demo, simplified a little:
#include <GuiConstantsEx.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Global $hItem[5], $hTreeView
Global $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

GUICreate("TreeView Expand", 400, 300)
$hTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
For $x = 0 To 4
    $hItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $hTreeView)
    For $y = 0 To 2
        GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $y), $hItem[$x])
    Next
Next
GUISetState()

MsgBox(4160, "Information", "Expand All")
_GUICtrlTreeView_Expand($hTreeView)

MsgBox(4160, "Information", "Collapse All")
_GUICtrlTreeView_Expand($hTreeView, 0, False)

MsgBox(4160, "Information", "Expand item 1")
_GUICtrlTreeView_Expand($hTreeView, $hItem[1])

MsgBox(4160, "Information", "Collapse item 1")
_GUICtrlTreeView_Expand($hTreeView, $hItem[1], False)

; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

That works fine.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

hmm perhaps it has to do with the way i destroy and rebuild it? it does the expanding collapsing just fine after that though

GUISwitch($MustHave_Edit_GUI)
    _GUICtrlTreeView_Destroy($treeview)
    
    BuildTree()
    
    _GUICtrlTreeView_Expand($treeview, 0, True)
    _GUICtrlTreeView_Expand($treeview, 0, False)
    
    _GUICtrlTreeView_Expand($treeview, $parent, True)
Edited by gcue

Share this post


Link to post
Share on other sites

duh - of course.. recreating treeview was gonna generate new control ids :)

Share this post


Link to post
Share on other sites

How could I just Expand one level of the tree, without expanding the whole tree under the parent.

Share this post


Link to post
Share on other sites

How could I just Expand one level of the tree, without expanding the whole tree under the parent.

Look at sources

"C:\Program Files\AutoIt3\Include\guitreeview.au3" 

_GUICtrlTreeView_Expand()

_GUICtrlTreeView_ExpandItem()

Share this post


Link to post
Share on other sites

Look at sources

"C:\Program Files\AutoIt3\Include\guitreeview.au3"

_GUICtrlTreeView_Expand()

_GUICtrlTreeView_ExpandItem()

hi Zedna,

Instead of using _GUICtrlTreeView_Expand(), I find the Item through the tree first, then expand it in the end.

Thanks for your suggestion anyway.

I have another query about how to get Item highlighted in the treeview so that the relevant info can be displayed on the other side of the window.

Thanks

post-48914-1240841292_thumb.png

Share this post


Link to post
Share on other sites

I have another query about how to get Item highlighted in the treeview so that the relevant info can be displayed on the other side of the window.

Thanks

Also look at

_GUICtrlTreeView_GetSelection()

Share this post


Link to post
Share on other sites

Also look at

_GUICtrlTreeView_GetSelection()

Thanks Zedna.

I use _GUICtrlTreeView_ClickItem() instead and It works fine.

I'm stucked by the same item names in a treeview. I really wanna expand the second, but it will find the other one first. Any idea for this? They locates under the different child trees, but from the same root.

Share this post


Link to post
Share on other sites

Found the solution, while looking in the source of _GuiCtrlTreeView_ExpandItem:

; $hTreeView = Handle to your TreeView Control
; $hItem = Handle to your TreeView Item
_SendMessage($hTreeView, $TVM_EXPAND, $TVE_EXPAND, $hItem, 0, "wparam", "handle")
  _SendMessage($hTreeView, $TVM_ENSUREVISIBLE, 0, $hItem, 0, "wparam", "handle")

Share this post


Link to post
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
Sign in to follow this  
Followers 0