Jump to content
Sign in to follow this  

TreeView problem.

Recommended Posts

Sample -

#include <GUIConstants.au3>
#Include <GuiTreeView.au3>

GUICreate('TreeView Test', 120, 160)

$tv_main = GUICtrlCreateTreeView(10, 10, 100, 110, -1, $WS_EX_CLIENTEDGE)
$tvi_1 = GUICtrlCreateTreeViewItem('Parent', $tv_main)

_GUICtrlTreeViewSetState($tv_main, $tvi_1, $TVIS_EXPANDED)
_GUICtrlTreeViewSetState($tv_main, $tvi_1, $TVIS_BOLD)

GUICtrlCreateTreeViewItem('Child 1', $tvi_1)
GUICtrlCreateTreeViewItem('Child 2', $tvi_1)
$tvc_3 = GUICtrlCreateTreeViewItem('Child 3', $tvi_1)
GUICtrlCreateTreeViewItem('Child 4', $tvi_1)
GUICtrlCreateTreeViewItem('Child 5', $tvi_1)

_GUICtrlTreeViewSetState($tv_main, $tvc_3, $TVIS_SELECTED)

$btn = GUICtrlCreateButton('Selected', 10, 130, 100, 20)


    $msg = GUIGetMsg()
    If $msg = $btn Then
        $tv_msg = GUICtrlSendMsg($tv_main, $TVM_GETNEXTITEM, $TVGN_CARET, 0)
        MsgBox(0, '', _GUICtrlTreeViewGetText($tv_main, $tv_msg))
Until $msg = $GUI_EVENT_CLOSE

With _GUICtrlTreeViewSetState($tv_main, $tvc_3, $TVIS_SELECTED) set, $tvc_3 (Child 3) seems to be selected when the script starts, but if you click the 'selected' button, it says the parent is selected. If you click any item other than 'Child 3,' the 'selected' button returns the proper item, but 'Child 3' remains selected. Clicking 'Child 3' then causes expected behavior. Am I misunderstanding how $TVIS_SELECTED is supposed to work?

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...