872777825 发表于 2011-3-11 16:30:42

如何在建立复选框的子复选框[已解决]

本帖最后由 872777825 于 2011-3-11 17:54 编辑




如图 小弟想 每个复选框下还有其他复选框
但搜索了下站内帖子好像没搜到相关帖子只好发帖求助

望有老师能帮忙解决下谢谢

搞定了
$TvDesktop = GUICtrlCreateTreeView(0, 0, 226, 225, BitOR($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS,$TVS_CHECKBOXES,$WS_GROUP,$WS_TABSTOP))
$TvDesktop_0 = GUICtrlCreateTreeViewItem("13123", $TvDesktop)

谢谢水木子

水木子 发表于 2011-3-11 17:11:08

直接用Treeview不是更好吗!

872777825 发表于 2011-3-11 17:33:20

恩 就是要这样的效果    水木子老师能给我提供点源码不
看帮助得出的例子不一样

872777825 发表于 2011-3-11 17:33:44

就给你出图片上的那点代码就好 {:face (396):}

872777825 发表于 2011-3-11 17:34:06

回复 2# 水木子


先谢谢了

水木子 发表于 2011-3-11 20:03:55

回复 5# 872777825 #include <GuiTreeView.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)
$hGUI = GUICreate("Treeview", 400, 300)
$hTreeview = GUICtrlCreateTreeView(2, 2, 180, 290, $iStyle, $WS_EX_CLIENTEDGE)
GUICtrlSetImage(-1, 'shell32.dll', 14)
$hFitem01 = GUICtrlCreateTreeViewItem("项目1", $hTreeview)
$hSitem01 = GUICtrlCreateTreeViewItem("项目1-1", $hFitem01)
$hSitem02 = GUICtrlCreateTreeViewItem("项目1-2", $hFitem01)
$hSitem03 = GUICtrlCreateTreeViewItem("项目1-3", $hFitem01)
GUICtrlSetState($hFitem01, $GUI_EXPAND)

$hFitem02 = GUICtrlCreateTreeViewItem("项目2", $hTreeview)
$hSitem11 = GUICtrlCreateTreeViewItem("项目2-1", $hFitem02)
$hSitem12 = GUICtrlCreateTreeViewItem("项目2-2", $hFitem02)
$hSitem13 = GUICtrlCreateTreeViewItem("项目2-3", $hFitem02)
GUICtrlSetState($hFitem02, $GUI_EXPAND)
GUISetState()

While 1
        Switch GUIGetMsg()
                Case - 3
                        Exit
                Case $hFitem01, $hFitem02
                        If BitAND(GUICtrlRead($hFitem01), $GUI_CHECKED) Then
                                GUICtrlSetState($hSitem01, $GUI_CHECKED)
                                GUICtrlSetState($hSitem02, $GUI_CHECKED)
                                GUICtrlSetState($hSitem03, $GUI_CHECKED)
                        ElseIf BitAND(GUICtrlRead($hFitem01), $GUI_UNCHECKED) Then
                                GUICtrlSetState($hSitem01, $GUI_UNCHECKED)
                                GUICtrlSetState($hSitem02, $GUI_UNCHECKED)
                                GUICtrlSetState($hSitem03, $GUI_UNCHECKED)
                        EndIf

                        If BitAND(GUICtrlRead($hFitem02), $GUI_CHECKED) Then
                                GUICtrlSetState($hSitem11, $GUI_CHECKED)
                                GUICtrlSetState($hSitem12, $GUI_CHECKED)
                                GUICtrlSetState($hSitem13, $GUI_CHECKED)
                        ElseIf BitAND(GUICtrlRead($hFitem02), $GUI_UNCHECKED) Then
                                GUICtrlSetState($hSitem11, $GUI_UNCHECKED)
                                GUICtrlSetState($hSitem12, $GUI_UNCHECKED)
                                GUICtrlSetState($hSitem13, $GUI_UNCHECKED)
                        EndIf
                Case $hSitem01, $hSitem02, $hSitem03, $hSitem11, $hSitem12, $hSitem13
                        If BitAND(GUICtrlRead($hSitem01), $GUI_CHECKED) = 1 Or BitAND(GUICtrlRead($hSitem02), $GUI_CHECKED) = 1 Or BitAND(GUICtrlRead($hSitem03), $GUI_CHECKED) = 1 Then
                                GUICtrlSetState($hFitem01, $GUI_CHECKED)
                        Else
                                GUICtrlSetState($hFitem01, $GUI_UNCHECKED)
                        EndIf

                        If BitAND(GUICtrlRead($hSitem11), $GUI_CHECKED) = 1 Or BitAND(GUICtrlRead($hSitem12), $GUI_CHECKED) = 1 Or BitAND(GUICtrlRead($hSitem13), $GUI_CHECKED) = 1 Then
                                GUICtrlSetState($hFitem02, $GUI_CHECKED)
                        Else
                                GUICtrlSetState($hFitem02, $GUI_UNCHECKED)
                        EndIf
        EndSwitch
WEnd

虎虎虎 发表于 2012-8-16 22:59:51

不错,很值得深入学习一下。
页: [1]
查看完整版本: 如何在建立复选框的子复选框[已解决]