求教大侠指点treeview如何点击子项获取父项的文本!
本帖最后由 qsy666888 于 2014-5-19 21:42 编辑比如
+AAA
-123
-456
在点击 123的时候可以取出123,AAA的文本
在点击 456的时候可以取出456,AAA的文本 #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', 300, 300)
$Treeview1 = GUICtrlCreateTreeView(2, 2, 296, 296)
GUICtrlSetImage(-1, 'shell32.dll', 5)
$Fitem1 = GUICtrlCreateTreeViewItem('项目1', $Treeview1)
$Sitem1_1 = GUICtrlCreateTreeViewItem('项目1-1', $Fitem1)
$Sitem1_2 = GUICtrlCreateTreeViewItem('项目1-2', $Fitem1)
$Sitem1_3 = GUICtrlCreateTreeViewItem('项目1-3', $Fitem1)
GUICtrlSetState($Fitem1, $GUI_EXPAND)
$Fitem2 = GUICtrlCreateTreeViewItem('项目2', $Treeview1)
$Sitem2_1 = GUICtrlCreateTreeViewItem('项目2-1', $Fitem2)
$Sitem2_2 = GUICtrlCreateTreeViewItem('项目2-2', $Fitem2)
$Sitem2_3 = GUICtrlCreateTreeViewItem('项目2-3', $Fitem2)
GUICtrlSetState($Fitem2, $GUI_EXPAND)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Sitem1_1, $Sitem1_2, $Sitem1_3, $Sitem2_1, $Sitem2_2, $Sitem2_3
$iFitemID = _GUICtrlTreeView_GetParentParam($Treeview1, $nMsg)
$sItemText = _GUICtrlTreeView_GetText($Treeview1, $iFitemID)
MsgBox(0, '被点击项目ID = ' & $nMsg, '父项目ID = ' & $iFitemID & @CRLF & '父项目文本 = ' & $sItemText)
EndSwitch
WEnd
回复 2# 水木子
这么难的问题你都能解决啊
能帮我看看http://www.autoitx.com/thread-44379-1-1.html这个吗,谢谢
页:
[1]