Jump to content

Recommended Posts

Posted

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)

Posted

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
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
  • 1 month later...
Posted

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

Posted

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.

  • 2 years later...
Posted

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")

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
  • Recently Browsing   0 members

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