我想在 RichTextBox 中创建上下文菜单。当我右键单击 RichTextBox 时,我需要剪切、复制、粘贴选项。
最佳答案
来自Microsoft Docs :
Private Sub InitializeMyContextMenu()
' Create the contextMenu and the MenuItem to add.
Dim contextMenu1 As New ContextMenu()
Dim menuItem1 As New MenuItem("C&ut")
Dim menuItem2 As New MenuItem("&Copy")
Dim menuItem3 As New MenuItem("&Paste")
' Use the MenuItems property to call the Add method
' to add the MenuItem to the MainMenu menu item collection.
contextMenu1.MenuItems.Add(menuItem1)
contextMenu1.MenuItems.Add(menuItem2)
contextMenu1.MenuItems.Add(menuItem3)
' Assign mainMenu1 to the rich text box.
richTextBox1.ContextMenu = contextMenu1
End Sub
关于.net - 如何在 RichTextBox 中创建上下文菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4907627/