帮帮忙,怎么在TREEVIEW中NODE加入右键弹出菜单?

supergecko 2001-12-04 07:48:34
 帮帮忙,怎么在TREEVIEW中NODE加入右键弹出菜单?
...全文
94 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
playyuer 2001-12-04
  • 打赏
  • 举报
回复
Option Explicit
Private Sub Form_Load()
Dim i As Integer
TreeView1.Style = tvwTreelinesPlusMinusPictureText
For i = 1 To 50
TreeView1.Nodes.Add , , GetNextKey, "Node " & i
Next i
TreeView1.HideSelection = False
TreeView1.LabelEdit = tvwManual
End Sub
Private Sub TreeView1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbRightButton And TreeView1.HitTest(x, y) Is TreeView1.SelectedItem Then
MenuNodesNodeX.Caption = TreeView1.SelectedItem.Text
Me.PopupMenu MenuNodes 'MenuNodes -> MenuNodesNodeX 为菜单
End If
End Sub
Private Function GetNextKey() As String
Dim sNewKey As String
Dim iHold As Integer
Dim i As Integer
On Error GoTo myerr
iHold = Val(TreeView1.Nodes(1).Key)
For i = 1 To TreeView1.Nodes.Count
If Val(TreeView1.Nodes(i).Key) > iHold Then
iHold = Val(TreeView1.Nodes(i).Key)
End If
Next
iHold = iHold + 1
sNewKey = VBA.CStr(iHold) & "_"
GetNextKey = sNewKey
Exit Function
myerr:
GetNextKey = "1_"
End Function

7,762

社区成员

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

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