CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2007
    Posts
    28

    ContextMenuStrip in RichTextBox

    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

    Code:
       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

  2. #2
    Join Date
    Mar 2008
    Posts
    142

    Re: ContextMenuStrip in RichTextBox

    u can mouse up event for this purpse
    Code:
    If e.Button = Windows.Forms.MouseButtons.Right Then
    ContextMenuStrip1.Show(MousePosition, Right)

  3. #3
    Join Date
    Aug 2007
    Posts
    28

    Re: ContextMenuStrip in RichTextBox

    ^^ Thanks

  4. #4
    Join Date
    Mar 2008
    Posts
    142

    Angry Re: ContextMenuStrip in RichTextBox

    Good if ur problem solved
    last time i did mistakes
    u can do it as also
    Code:
     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

  5. #5
    Join Date
    Oct 2015
    Location
    Kenya
    Posts
    11

    Re: ContextMenuStrip in RichTextBox

    Quote Originally Posted by imname View Post
    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

    Code:
       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

    Can you help me use this code for a spellchecker suggester?

  6. #6
    Join Date
    Oct 2015
    Location
    Kenya
    Posts
    11

    Re: ContextMenuStrip in RichTextBox

    How can I use this code for a spell checker suggester?

  7. #7
    Join Date
    Oct 2015
    Location
    Kenya
    Posts
    11

    Re: ContextMenuStrip in RichTextBox

    Can you help me use this code for a spellchecker suggester?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured