开发者

How to create a context menu in a RichTextBox

开发者 https://www.devze.com 2023-02-09 06:01 出处:网络
I want to create a context menu in a RichTextBox. I want C开发者_Python百科ut, Copy, Paste options when I right click on the RichTextBox.From Microsoft Docs:

I want to create a context menu in a RichTextBox. I want C开发者_Python百科ut, Copy, Paste options when I right click on the RichTextBox.


From 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
0

精彩评论

暂无评论...
验证码 换一张
取 消