代码如下所示:
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
If Node.Text = "计算机系" Then MsgBox "1"
If Node.Text = "经管系" Then MsgBox "2"
End Sub
运行截图:
在代码窗口选择treeview,选择NodeClick事件。它传递的Node对象就是被点击的那个Node。因此,你可以采用以下代码:
Private Sub TreeView1_NodeClick(ByVal Node As ComctlLib.Node)
If Node.Text = "计算机系" Then Msgbox 1 If Node.Text = "经管系" Then Msgbox 2End Sub
参看:网页链接