我的表单中有一个treeview控件。我希望能够编辑树中的节点并将更改推送到Access DB。但是,我找不到合适的事件。 MSDN treeview events reference page建议 AfterLabelEdit ,但我无法让它发挥作用。有人知道任何解决方法/解决方案吗? 我使用的代码片段(我已添加 onClick 和 onDblClick 进行比较,因为它们有效):
Private Sub xMyTreeview_Click() 'OK
testit
End Sub
Private Sub xMyTreeview_DblClick() 'OK
EditLabel
End Sub
Private Sub xMyTreeview_AfterLabelEdit() 'Problem
AfterLabel
End Sub
Sub EditLabel()
Me.xMyTreeview.StartLabelEdit
End Sub
Sub AfterLabel()
MsgBox prompt, vbOKOnly, "afterlabel"
End Sub
Sub testit()
Dim nodSelected As MSComctlLib.Node ' a variable for the currently selected node
Set nodSelected = Me.xMyTreeview.SelectedItem ' get the currently selected node
NodesStrLength = Len(nodSelected.Key)
Dim NodeStr As String
Dim StrToChange As String
StrToChange = nodSelected.Key
NodeStr = Mid(StrToChange, 2, NodesStrLength - 1)
Me.txtNodeID = NodeStr
Me.sfrmDOCNODE.Visible = True
End Sub
答案 0 :(得分:0)
您的链接是.net Windows窗体树视图,但MSComctlLib
是较早的Visual Basic公共控件:http://msdn.microsoft.com/en-us/library/aa443023(v=vs.60).aspx
注意事件原型是不同的;如果你没有用正确的参数声明它,它永远不会被引发;
Private Sub object_AfterLabelEdit(cancel As Integer, newstring As String)