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

Rich Text Box how to highlight text block

Yes you can set the BackColor of a RichTextBox Selection using the RichTextBox.SelectionBackColor Property. int blockStart = 1; //arbitrary numbers to test int blockLength = 15; richTextBox1.SelectionStart = blockStart; richTextBox1.SelectionLength = blockLength; richTextBox1.SelectionBackColor = Color.Yellow;

Get current scroll position from rich text box control?

This should get you close to what you are looking for. This class inherits from the RichTextBox and uses some pinvoking to determine the scroll position. It adds an event ScrolledToBottom which gets fired if the user scrolls using the scrollbar or uses the keyboard. public class RTFScrolledBottom : RichTextBox { public event EventHandler ScrolledToBottom; … Read more

Selectively coloring text in RichTextBox

Try this: static void HighlightPhrase(RichTextBox box, string phrase, Color color) { int pos = box.SelectionStart; string s = box.Text; for (int ix = 0; ; ) { int jx = s.IndexOf(phrase, ix, StringComparison.CurrentCultureIgnoreCase); if (jx < 0) break; box.SelectionStart = jx; box.SelectionLength = phrase.Length; box.SelectionColor = color; ix = jx + 1; } box.SelectionStart = … Read more

Clicking HyperLinks in a RichTextBox without holding down CTRL – WPF

I found a solution. Set IsDocumentEnabled to “True” and set IsReadOnly to “True”. <RichTextBox IsReadOnly=”True” IsDocumentEnabled=”True” /> Once I did this, the mouse would turn into a ‘hand’ when I hover over a text displayed within a HyperLink tag. Clicking without holding control will fire the ‘Click’ event. I am using WPF from .NET 4. … Read more

How to use multi color in richtextbox [duplicate]

System.Windows.Forms.RichTextBox has got a property of type Color of the name SelectionColor which gets or sets the text color of the current selection or insertion point. You can use this property to mark specific fields in your RichTextBox with the colors you specify. Example RichTextBox _RichTextBox = new RichTextBox(); //Initialize a new RichTextBox of name … Read more