Hi,
ich will mir eine GUI mit TreeView aufbauen.
Wenn ich ein Item anhake soll sofort (ohne einen Button zu drücken) die Subitems abgehakt und deaktiviert werden.
Wenn ich ein Item abhake soll sofort (ohne einen Button zu drücken) die Subitems aktiviert werden.
Wie mache ich das.
PS: Wie würdet ihr z. B. Dim $hauptitem[10] dimensionieren, da sich die Anzahl der Items variabel sein wird?
Spoiler anzeigen
#include <GuiTreeView.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>
Dim $hauptitem[10]
Dim $hItem[10][10]
Dim $status[10][10]
Dim $status_hauptitem[10]
Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)
$GUI = GUICreate("(UDF Created) TreeView Create", 400, 300)
$hTreeView = _GUICtrlTreeView_Create($GUI, 2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
GUISetState()
_GUICtrlTreeView_BeginUpdate($hTreeView)
For $x = 1 To 4
$hauptitem[$x] = _GUICtrlTreeView_Add($hTreeView, 0, StringFormat("[%02d] New Item", $x))
For $y = 1 To 5
$hItem[$x][$y] = _GUICtrlTreeView_AddChild($hTreeView, $hauptitem[$x], StringFormat("[%02d] New Child", $y))
Next
Next
_GUICtrlTreeView_EndUpdate($hTreeView)
Sleep(3000)
[/autoit] [autoit][/autoit] [autoit]For $x = 1 To 4
$status_hauptitem[$x] = _GUICtrlTreeView_GetChecked($hTreeView, $hauptitem[$x])
$text_hauptitem = _GUICtrlTreeView_GetText($hTreeView, $hauptitem[$x])
If $status_hauptitem[$x] = True Then
ConsoleWrite($text_hauptitem & @CRLF)
Else
For $y = 1 To 5
$text_subitem = _GUICtrlTreeView_GetText($hTreeView, $hItem[$x][$y])
$status[$x][$y] = _GUICtrlTreeView_GetChecked($hTreeView, $hItem[$x][$y])
If $status[$x][$y] = True Then ConsoleWrite($text_hauptitem & " | " & $text_subitem & @CRLF)
Next
EndIf
Next
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
;~ EndFunc ;==>_Main