Click to See Complete Forum and Search --> : ContextMenuStrip in RichTextBox


imname
June 30th, 2008, 11:01 PM
How can I show ContextMenuStrip in RichTextBox when I highlight a word and right click the mouse?

The code below only show the ContextMenuStrip when I double click in the RichTextBox


Private Sub rtb_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles rtb.MouseDoubleClick
ContextMenuStrip1.Show(MousePosition, Right)
End Sub


Thanks

aamir55
July 1st, 2008, 08:36 AM
u can mouse up event for this purpse

If e.Button = Windows.Forms.MouseButtons.Right Then
ContextMenuStrip1.Show(MousePosition, Right)

imname
July 2nd, 2008, 04:51 AM
^^ Thanks

aamir55
July 2nd, 2008, 08:18 AM
Good if ur problem solved
last time i did mistakes
u can do it as also

Private Sub RichTextBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles RichTextBox1.MouseUp
If e.Button = Windows.Forms.MouseButtons.Right Then
ContextMenuStrip1.Show(RichTextBox1, New Point(e.X, e.Y))
End If
End Sub