Created
June 21, 2013 07:29
-
-
Save michaelij/5829513 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Drawing; | |
using System.Text; | |
using System.Windows.Forms; | |
namespace Utilities | |
{ | |
/// <summary> | |
/// Extensions for System.Windows.Forms.RichTextBox | |
/// </summary> | |
public static class RichTextBoxExtensions | |
{ | |
/// <summary> | |
/// Appends colored text to the textbox | |
/// </summary> | |
/// <param name="textBox">The rich text box</param> | |
/// <param name="text">The text to append</param> | |
/// <param name="color">The color of the text</param> | |
public static void AppendText(this RichTextBox textBox, string text, Color color) | |
{ | |
textBox.SelectionStart = textBox.TextLength; | |
textBox.SelectionLength = 0; | |
textBox.SelectionColor = color; | |
textBox.AppendText(text); | |
textBox.SelectionColor = textBox.ForeColor; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment