chenzhi1210 发表于 2011-10-16 16:38:19

GUICtrlCreateTreeViewItem 怎么删除项目?[已解决]

本帖最后由 chenzhi1210 于 2011-10-16 23:50 编辑

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=D:\system\桌面\TreeView测试.kxf
$Form1 = GUICreate("TreeView测试", 186, 157, 585, 462)
$TreeView1 = GUICtrlCreateTreeView(16, 8, 153, 97)
$TreeView1_0 = GUICtrlCreateTreeViewItem("A组", $TreeView1)
$TreeView1_1 = GUICtrlCreateTreeViewItem("111", $TreeView1_0)
$TreeView1_2 = GUICtrlCreateTreeViewItem("222", $TreeView1_0)
$TreeView1_3 = GUICtrlCreateTreeViewItem("B组", $TreeView1)
$TreeView1_4 = GUICtrlCreateTreeViewItem("333", $TreeView1_3)
$Button1 = GUICtrlCreateButton("加载项目", 16, 120, 75, 25)
$Button2 = GUICtrlCreateButton("删除项目", 96, 120, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

                Case $Button1
                Case $Button2
        EndSwitch
WEnd


“加载项目”按扭点击后,TreeView中“A组,111,222,B组,333”这些项目,全部显示出来。
“删除项目”按扭点击后,TreeView中“A组,111,222,B组,333”全部删除掉。

请问怎么实现这两个按扭功能?

希望高手能够帮助,感激不尽!

afan 发表于 2011-10-16 21:22:52

#include <GuiTreeView.au3>

GUICreate('TreeView测试', 186, 157, 585, 462)
$hTreeView = GUICtrlCreateTreeView(16, 8, 153, 97)
$hItem_A = GUICtrlCreateTreeViewItem('A组', $hTreeView)
GUICtrlCreateTreeViewItem('111', $hItem_A)
GUICtrlCreateTreeViewItem('222', $hItem_A)
$hItem_B = GUICtrlCreateTreeViewItem('B组', $hTreeView)
GUICtrlCreateTreeViewItem('333', $hItem_B)
$Button1 = GUICtrlCreateButton('加载项目', 16, 120, 75, 25)
$Button2 = GUICtrlCreateButton('删除项目', 96, 120, 75, 25)
GUISetState(@SW_SHOW)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case -3
                        Exit
                Case $Button1
                        _GUICtrlTreeView_Expand($hTreeView)
                Case $Button2
                        _GUICtrlTreeView_Delete($hTreeView, $hItem_A)
                        _GUICtrlTreeView_Delete($hTreeView, $hItem_B)
                        GUICtrlSetState($Button1, 128)
        EndSwitch
WEnd

chenzhi1210 发表于 2011-10-16 23:49:47

非常感谢afan的帮忙!谢谢!

ap112 发表于 2014-7-15 14:21:54

学习学习。

ak47gglllk 发表于 2014-11-14 16:32:13

学习下,感谢,非常感谢
页: [1]
查看完整版本: GUICtrlCreateTreeViewItem 怎么删除项目?[已解决]