Treeview

  • Hallo.
    Ich wollte grade mal versuchen wie ein Treeview funktioniert.
    Hier ist es erstmal:

    Spoiler anzeigen
    [autoit]

    #cs ----------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    AutoIt Version: 3.3.2.0
    Author: myName

    [/autoit] [autoit][/autoit] [autoit]

    Script Function:
    Template AutoIt script.

    [/autoit] [autoit][/autoit] [autoit]

    #ce ----------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <TreeViewConstants.au3>
    #include <StaticConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $GUI1 = GUICreate("Treeview",750,500)
    $treeview = GUICtrlCreateTreeView(6, 6, 200, 490, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
    $TVI1 = GUICtrlCreateTreeViewItem("Allgemein",$treeview)
    $TVI2 = GUICtrlCreateTreeViewItem("Eine Zahl",$TVI1)
    $TVI3 = GUICtrlCreateTreeViewItem("Eine andre Zahl", $TVI1)

    [/autoit] [autoit][/autoit] [autoit]

    $2 = GUICtrlCreateLabel("2",300,210)
    GUICtrlSetState(-1, $GUI_HIDE)
    $4 = GUICtrlCreateLabel("4",300,210)
    GUICtrlSetState(-1, $GUI_HIDE)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    While 1

    [/autoit] [autoit][/autoit] [autoit]

    $msg = GUIGetMsg()

    [/autoit] [autoit][/autoit] [autoit]

    Select
    Case $msg = $GUI_EVENT_CLOSE
    ExitLoop

    [/autoit] [autoit][/autoit] [autoit]

    Case $msg = $TVI2
    GUICtrlSetState($2, $GUI_SHOW)
    Case $msg = $TVI3
    GUICtrlSetState($4, $GUI_SHOW)
    EndSelect
    WEnd

    [/autoit]

    Also, wenn ich auf Eine Zahl klicke dann erscheint die 2, und wenn ich auf Eine andre Zahl klicke dann erscheint die 4. Das ist ja schonmal gut.
    Aber wenn ich dann wieder auf Eine Zahl klicke dann bleibt die 4.
    Also brauche ich irgendeine Funktion, die die eine Zahl verschwinden lässt und die andere anzeigt!
    Ich habe keine Ahnung habe schon mehrere Sachen ausprobiert.
    Habt ihr eine Idee???

  • Ich habe eine Lösung gefunden.
    Nämlich einen externen Button, der die Labels versteckt.

    Spoiler anzeigen
    [autoit]

    #cs ----------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    AutoIt Version: 3.3.2.0
    Author: myName

    [/autoit] [autoit][/autoit] [autoit]

    Script Function:
    Template AutoIt script.

    [/autoit] [autoit][/autoit] [autoit]

    #ce ----------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <TreeViewConstants.au3>
    #include <StaticConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $GUI1 = GUICreate("Treeview",750,500)
    $treeview = GUICtrlCreateTreeView(6, 6, 200, 490, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
    $TVI1 = GUICtrlCreateTreeViewItem("Allgemein",$treeview)
    $TVI2 = GUICtrlCreateTreeViewItem("Eine Zahl",$TVI1)
    $TVI3 = GUICtrlCreateTreeViewItem("Eine andre Zahl", $TVI1)

    [/autoit] [autoit][/autoit] [autoit]

    $2 = GUICtrlCreateLabel("2",300,210)
    GUICtrlSetState(-1, $GUI_HIDE)
    $4 = GUICtrlCreateLabel("4",300,210)
    GUICtrlSetState(-1, $GUI_HIDE)
    $HIDEbutton = GUICtrlCreateButton("HIDE",400,300)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    While 1

    [/autoit] [autoit][/autoit] [autoit]

    $msg = GUIGetMsg()

    [/autoit] [autoit][/autoit] [autoit]

    Select
    Case $msg = $GUI_EVENT_CLOSE
    ExitLoop
    Case $msg = $HIDEbutton
    GUICtrlSetState($2,$GUI_HIDE)
    GUICtrlSetState($4,$GUI_HIDE)
    Case $msg = $TVI2
    GUICtrlSetState($2,$GUI_SHOW)
    Case $msg = $TVI3
    GUICtrlSetState($4,$GUI_SHOW)
    EndSelect
    WEnd

    [/autoit]

    Gibt es noch eine andre möglichkeit????

  • Warum verstecken und anzeigen? GUICtrlSetData.

    Spoiler anzeigen
    [autoit]

    #cs ----------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    AutoIt Version: 3.3.2.0
    Author: myName

    [/autoit] [autoit][/autoit] [autoit]

    Script Function:
    Template AutoIt script.

    [/autoit] [autoit][/autoit] [autoit]

    #ce ----------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <TreeViewConstants.au3>
    #include <StaticConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $GUI1 = GUICreate("Treeview",750,500)
    $treeview = GUICtrlCreateTreeView(6, 6, 200, 490, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
    $TVI1 = GUICtrlCreateTreeViewItem("Allgemein",$treeview)
    $TVI2 = GUICtrlCreateTreeViewItem("Eine Zahl",$TVI1)
    $TVI3 = GUICtrlCreateTreeViewItem("Eine andre Zahl", $TVI1)

    [/autoit] [autoit][/autoit] [autoit]

    $Lable = GUICtrlCreateLabel("",300,210)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    While 1 * Sleep(10)

    [/autoit] [autoit][/autoit] [autoit]

    $msg = GUIGetMsg()
    Switch $msg
    Case $GUI_EVENT_CLOSE
    ExitLoop

    [/autoit] [autoit][/autoit] [autoit]

    Case $TVI2
    GUICtrlSetData($Lable,"2")
    Case $TVI3
    GUICtrlSetData($Lable,"4")
    EndSwitch
    WEnd

    [/autoit]
  • :D Danke.
    Ich habe das mit dem verstecken und anzeigen gemacht, weil das die Hilfe auch so gemacht hat.
    Aber die Hilfe hat dann eine eigene Funktion erstellt die bei mir nicht so wirklich funktioniert.