locked
how to show HyperLinks in a RichTextBox? RRS feed

  • Question

  • i've been researched around but didn't find the right answer. I am using a Winform and in the rich text box i want to display a hyperlink in this format: google

    is there a way to achieve this?

    Any hint will be appreciated.

    Thursday, October 21, 2010 1:41 PM

Answers

  • Hello youkebb,

    To make the URLs in a RichTextBox launch a browser, add code to handle the LinkClicked event:

    protected void Link_Clicked (object sender, System.Windows.Forms.LinkClickedEventArgs e)
    {
        System.Diagnostics.Process.Start(e.LinkText);
    }


    And then, tie this handler to the RichTextBox's LinkClicked event:
    myRichTextBox.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(Link_Clicked);
    Regards,
    Helen Zhou

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Marked as answer by Helen Zhou Friday, October 29, 2010 9:20 AM
    Monday, October 25, 2010 3:03 AM

All replies

  • Hello youkebb,

    To make the URLs in a RichTextBox launch a browser, add code to handle the LinkClicked event:

    protected void Link_Clicked (object sender, System.Windows.Forms.LinkClickedEventArgs e)
    {
        System.Diagnostics.Process.Start(e.LinkText);
    }


    And then, tie this handler to the RichTextBox's LinkClicked event:
    myRichTextBox.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(Link_Clicked);
    Regards,
    Helen Zhou

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Marked as answer by Helen Zhou Friday, October 29, 2010 9:20 AM
    Monday, October 25, 2010 3:03 AM
  • Hi,

    you can add a linkedlable control into richtextbox, then do linkedclick event.

    hope helps

    best regards

    vincin

    Monday, October 25, 2010 3:56 AM