Today I learned that the default RichTextBox control does not handle hyperlinks out of the box. If you do want to have hyperlinks work, you need to do the following:
- DetectUrls property on the RichTextBox control is set to True
- Open the Designer.cs file and find the generated code block for the RichTextBlock properties and handlers. Add the following line:
this.myRichTextBox.LinkClicked +=
new LinkClickedEventHandler (this.myRichTextBox_LinkClicked);
- Add the eventhandler to the .cs file:
private void myRichTextBox_LinkClicked(object sender, LinkClickedEventArgs e) {
System.Diagnostics.Process.Start(e.LinkText);
}
That is it...