Tag Archives: Rich Text box

Find the word under the mouse in a RichTextBox control in C#

The following WordUnderMouse method returns the word under the mouse in a RichTextBox. // Return the word under the mouse. private string WordUnderMouse(RichTextBox rch, int x, int y) { // Get the character’s position. int pos = rch.GetCharIndexFromPosition(new Point(x, y)); … Continue reading

Posted in controls, miscellany | Tagged , , , , , , , , , , , | 2 Comments

Set RichTextBox tab stops in C#

You can set different RichTextBox tab stops for different parts of a RichTextBox control’s text. This example uses the following code to set tabs for the whole control and then adds some text to it that includes tabs. // Set … Continue reading

Posted in controls | Tagged , , , , , , , , , , , , , , | Leave a comment

Format text in a RichTextBox in C#

To format text in a RichTextBox, use the control’s Select method to select the text. Then use the “Selection” properties (SelectionAlignment, SelectionBackColor, SelectionFont, etc.) to set the properties for the selected text. This example uses the following code to format … Continue reading

Posted in controls | Tagged , , , , , , , , , , , | 2 Comments