Send a suggestion!

We're building a brand new version of the site, and we'd love to hear your ideas

Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 18,902 times

Related Categories

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

© 2001 Element K Journals, a division of Element K Press LLC ("Element K"). Element K and the Element K logo are trademarks of Element K LLC

Comments