还是Treeview的问题。继续讨论~~

CsdnLamia 2003-09-08 03:22:24
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






这样一个结构的Treeview. 我怎么判断我所点击的node.text是在"测试A"的目录下面
还是在B的目录下面, 或者就是判断relative是A还是B.
...全文
100 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
yijiansong 2003-09-08
  • 打赏
  • 举报
回复
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
If Left(Node.Key, 1) = "A" Then MsgBox "a"
If Left(Node.Key, 1) = "B" Then MsgBox "b"

End Sub
kmzs 2003-09-08
  • 打赏
  • 举报
回复
还有啥问题,treeview我玩的不少了,除了和数据库相关的别问我。。。
lisong770818 2003-09-08
  • 打赏
  • 举报
回复
aierong(pengdali(大力V1.0)的徒弟) ) 完全符合你提的问题。我赞同
aierong 2003-09-08
  • 打赏
  • 举报
回复
利用你的节点关键字

Dim nodx As Node

Private Sub Form_Load()
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")

End Sub

Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
If Left(Node.Key, 1) = "A" Then MsgBox "a"
If Left(Node.Key, 1) = "B" Then MsgBox "b"

End Sub
CsdnLamia 2003-09-08
  • 打赏
  • 举报
回复
我已经解决了。

If Node.Parent.Key = "A" Then

msgbox "ok"

end if
strongfisher 2003-09-08
  • 打赏
  • 举报
回复
判断Node.Parent.Text
if Node.Parent.Text ="A" then
msgbox a
elseif Node.Parent.Text ="B" then

msgbox b
endif
射天狼 2003-09-08
  • 打赏
  • 举报
回复
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
If Not (Node.Parent Is Nothing) Then MsgBox Node.Parent.Text
End Sub

7,789

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧