1

我的表单中有一个树视图控件。我希望能够编辑树中的节点并将更改推送到 Access DB。但是,我很难找到合适的活动。MSDN treeview 事件参考页面建议AfterLabelEdit,但我无法让它工作。有人知道任何解决方法/解决方案吗?我使用的代码片段(我添加了onClickonDblClick进行比较,因为它们有效):

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
4

1 回答 1

1

您的链接是 .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)
于 2013-04-25T16:30:05.510 回答