How can I make a hyperlink work in a RichTextBox?

Make sure the text property includes a valid url. E.g. http://www.stackoverflow.com/ set the DetectUrls property to true Write an event handler for the LinkClicked event. Personally, I wouldn’t pass “IExplore.exe” in as a parameter to the Process.Start call as Microsoft advise as this presupposes that it is installed, and is the user’s preferred browser. If … Read more

Richtextbox wpf binding

There is a much easier way! You can easily create an attached DocumentXaml (or DocumentRTF) property which will allow you to bind the RichTextBox‘s document. It is used like this, where Autobiography is a string property in your data model: <TextBox Text=”{Binding FirstName}” /> <TextBox Text=”{Binding LastName}” /> <RichTextBox local:RichTextBoxHelper.DocumentXaml=”{Binding Autobiography}” /> Voila! Fully bindable … Read more

Rich Text box scroll to the bottom when new data is written to it

Yes, you can use the ScrollToCaret() method: // bind this method to its TextChanged event handler: // richTextBox.TextChanged += richTextBox_TextChanged; private void richTextBox_TextChanged(object sender, EventArgs e) { // set the current caret position to the end richTextBox.SelectionStart = richTextBox.Text.Length; // scroll it automatically richTextBox.ScrollToCaret(); }

Color different parts of a RichTextBox string

Here is an extension method that overloads the AppendText method with a color parameter: public static class RichTextBoxExtensions { public static void AppendText(this RichTextBox box, string text, Color color) { box.SelectionStart = box.TextLength; box.SelectionLength = 0; box.SelectionColor = color; box.AppendText(text); box.SelectionColor = box.ForeColor; } } And this is how you would use it: var userid … Read more