How to create a context menu in a RichTextBox
10,122
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
Author by
SpongeBob SquarePants
Top Secret I live Deep down in the Pacific Ocean in the subterranean city of Bikini Bottom in a pineapple along with my pet Gary. I make delicious Krabby Patty Burger at Krusty Krabs. My favorite quote: Isn't this great Squidward? Its just the 3 of us. You, me, and this brick wall you built between us
Updated on June 04, 2022Comments
-
SpongeBob SquarePants almost 2 years
I want to create a context menu in a RichTextBox. I want Cut, Copy, Paste options when I right click on the RichTextBox.