Library code snippets
Add pop-up menu support to the Rich Textbox control
While Visual Basic provides an easy way to create shortcut menus, some controls
such as rich text boxes don't inherently support pop-up menus. To overcome this
obstacle, you can take advantage of the MouseDown() event. Visual Basic triggers
this event when you press the mouse button. To provide a pop-up menu, create
a
shortcut menu, then simply call it in the control's MouseDown() event.
To see how this works, add a Rich Textbox control to a sample form. Next, select
Tools | Menu Editor from Visual Basic's IDE menu bar, and create a simple menu
with one or two items. Then, switch to the form's code window, and enter Private Sub RichTextBox1_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
Me.PopupMenu Menu
End IF
End Sub
Related articles
Related discussion
-
Regarding Visual Basic Programme
by manjunathsl2007 (0 replies)
-
how do you hide all in VB6
by CapnJack (1 replies)
-
Problem with Input File
by novavb6 (3 replies)
-
How to produce a txt file with a table??
by novavb6 (1 replies)
-
VB6 compatability from XP to Vista
by bronx (1 replies)
This thread is for discussions of Add pop-up menu support to the Rich Textbox control.