Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8610405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:07:17+00:00 2026-06-12T04:07:17+00:00

I have a link in a richtextbox in C#. When I right on a

  • 0

I have a link in a richtextbox in C#. When I right on a url link, I want to show a menu. if it is not a url, then I do not want to show anything. Right now I am tapping into the mouse down event and selecting the line based on the mouse pointer position and if the selected line is a valid url, I show the menu. it works great, but when I have some text next to the url, still the line is detected as a valid url and the menu appears. Also I am unable to tap into the mouse changed event as well. Any ideas on how I could accomplish what I am trying to do?

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:07:18+00:00Added an answer on June 12, 2026 at 4:07 am

    Not sure if this is what you are looking for, but I believe that you’ll find better than this

    You may try this when the MouseDown is called

    private void richTextBox1_MouseDown(object sender, MouseEventArgs e)
    {
        // Continue if the Right mouse button was clicked
        if (e.Button == MouseButtons.Right)
        {
            // Check if the selected item starts with http://
            if (richTextBox1.SelectedText.IndexOf("http://") > -1)
            {
                // Avoid popping the menu if the value contains spaces
                if (richTextBox1.SelectedText.Contains(' '))
                {
                   // Show the menu
                   contextMenuStrip1.Show(Cursor.Position.X, Cursor.Position.Y);
                }
            }   
        }
    }
    

    Or this when a Link is Clicked, but this won’t apply for Mouse Right-Click

    private void richTextBox1_LinkClicked(object sender, LinkClickedEventArgs e)
    {
         contextMenuStrip1.Show(Cursor.Position.X, Cursor.Position.Y);
    }
    

    Thanks,

    I hope this helps 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have link for example domain.com/de/controler/action?param=value and I want make actionlink to keep same
I have this link in a template: <a href={% url show_item item.id %}>Item 1</a>
I have a link, with which i want use plus, which will change color
I have a link which looks like that: www.domain.com/file.php I want to create .htaccess
I have a link that I want to center vertically in the .well class
I have link change password in my home page..NOw i am telling you what
I have 3 tables Links Link ID Link Name GroupID (FK into Groups) SubGroupID
i have link of home page in html page i want it to go
I want to replace a regular link with a hyperlink in my RichTextBox, all
i have link like this i need show detail of city in dialog box

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.