vb实现treeview右键弹出不同的子菜单
下面代码弹出来的是相同的菜单,怎样根据不同的节点弹出不同的子菜单呢?PrivateSubTreeView1_MouseUp(ButtonAsInteger,ShiftAs...
下面代码弹出来的是相同的菜单,怎样根据不同的节点弹出不同的子菜单呢?
Private Sub TreeView1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then PopupMenu edit
End Sub 展开
Private Sub TreeView1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then PopupMenu edit
End Sub 展开
1个回答
展开全部
再加一些菜单
Private Sub TreeView1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
select case treeview1.nodes.key
case ??
PopupMenu edit1
case ???
PopupMenu edit2
...
end select
End Sub
Private Sub TreeView1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
select case treeview1.nodes.key
case ??
PopupMenu edit1
case ???
PopupMenu edit2
...
end select
End Sub
追问
请问TreeView1.Nodes.Key表示什么?是节点的名称还是节点编号?case后面跟的是什么?谢谢
追答
是节点的key,节点名是可以重复的,但是每个节点有专有的key,就是关键字,相当于编号,每生成一个节点都必须赋给它key值的。这里用节点名还是用key取决于你自己的要求。比如说有个节点的key是12345,右击它时希望弹出菜单edit4
If Button = 2 Then
select case treeview1.nodes.key
case 12345
PopupMenu edit4
...
end select
或者你想要一类节点都弹出同一菜单,比如节点名含有“中国”的都弹出edit3
if button=2 then
if instr(treeview1.nodes.text,"中国") then popumenu edit3
或者是key为123的节点的所有子节点都弹出edit2
if treeview1.nodes.parant.key="123" then popupmenu edit2
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询