How to make hyperlink clickable in RichTextBox?

G

Guest

Hi,

I am using .NET 1.1. I put a web address to a RichTextBox and set its
DetectUrls property as true. After the app starts, it underline the link
automatically but I cannot click it.
How can I make it clickable in RichTextBox?
Thanks

Chris
 
C

Chris Hyde

chrisben said:
Hi,

I am using .NET 1.1. I put a web address to a RichTextBox and set its
DetectUrls property as true. After the app starts, it underline the link
automatically but I cannot click it.
How can I make it clickable in RichTextBox?
Thanks

Chris
You have to provide a handler for the LinkClicked event...something like
this:

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


Now, tie this handler to the RichTextBox's LinkClicked event:

myRichTextBox.LinkClicked +=
new System.Windows.Forms.LinkClickedEventHandler(
Link_Clicked);

HTH...

Chris
 
G

Guest

Thank you.

Chris Hyde said:
You have to provide a handler for the LinkClicked event...something like
this:

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


Now, tie this handler to the RichTextBox's LinkClicked event:

myRichTextBox.LinkClicked +=
new System.Windows.Forms.LinkClickedEventHandler(
Link_Clicked);

HTH...

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top