比如: Set nodx = Treeview1.Nodes.Add(, tvwFirst, "A", "测试A")
Set nodx = Treeview1.Nodes.Add("A", tvwChild, "A1", "A")
Set nodx = Treeview1.Nodes.Add("A", tvwChild, "A2", "AA")
Set nodx = Treeview1.Nodes.Add("A", tvwChild, "A3", "AAA")
Set nodx = Treeview1.Nodes.Add(, tvwFirst, "B", "测试B")
Set nodx = Treeview1.Nodes.Add("B", tvwChild, "B1", "B")
Set nodx = Treeview1.Nodes.Add("b", tvwChild, "B2", "BB")--A
-----A
-----AA
-----AAA
--B
_____B
-----BB
我要控制的是
如果点击 Root是A里面的子节点 就Msgbox "A"
如果点击 Root是B里面的子节点 就Msgbox "B"我写的,
If Node.Root.Text = "A" Then
msgbox "a"
elseif Node.Root.Text = "B" then
msgbox "b"
Endif 但是不行啊~~~~~~~~~~~~~~~~~ 谁帮我控制一下。
Set nodx = Treeview1.Nodes.Add("A", tvwChild, "A1", "A")
Set nodx = Treeview1.Nodes.Add("A", tvwChild, "A2", "AA")
Set nodx = Treeview1.Nodes.Add("A", tvwChild, "A3", "AAA")
Set nodx = Treeview1.Nodes.Add(, tvwFirst, "B", "测试B")
Set nodx = Treeview1.Nodes.Add("B", tvwChild, "B1", "B")
Set nodx = Treeview1.Nodes.Add("b", tvwChild, "B2", "BB")--A
-----A
-----AA
-----AAA
--B
_____B
-----BB
我要控制的是
如果点击 Root是A里面的子节点 就Msgbox "A"
如果点击 Root是B里面的子节点 就Msgbox "B"我写的,
If Node.Root.Text = "A" Then
msgbox "a"
elseif Node.Root.Text = "B" then
msgbox "b"
Endif 但是不行啊~~~~~~~~~~~~~~~~~ 谁帮我控制一下。
If Node.Parent.Text="A" Then
Msgbox "A"
End If
If Not (Node.Parent Is Nothing) Then MsgBox Node.Parent.Text
End Sub
If Not (Node.Parent Is Nothing) Then MsgBox Node.Parent.Text
判断了是否有父节点,是对应父节点的text(Node.Parent.Text)