Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
If TreeView1.SelectedItem.Children = 0 Then '检查是否有子节点,0为无
For i = 1 To TreeView1.Nodes.Count
If TreeView1.Nodes(i).Selected Then
MsgBox "选择的是:“" & TreeView1.Nodes(i).Text & "”子节点!"
End If
Next i
End If
End Sub
汗,你那也太麻烦了,并且效率也很低,完全没有必要.
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node) If Node.Children = 0 Then MsgBox "选择的是:“" & Node.Text & "”子节点!" End If
End Sub