Add styled text to RichTextBox

Add a text with a specific font and color to a RichTextBox control.

static class extensionMethods
  public static void AppendText(this RichTextBox textBox, string appendText, 
  System.Drawing.Color textColor = null, Font TextFont = null)
      textBox.SelectionStart = textBox.TextLength;
      textBox.SelectionLength = 0;
      if (textColor != null) textBox.SelectionColor = textColor;
      if (textFont != null)  textBox.SelectionFont = textFont;
      textBox.SelectionColor = textBox.ForeColor;
Lastest update in December 2019, inital post in December 2019

Write a comment

I appreciate comments, suggestions, compliments etc. Unfortunately I have no time to reply to them. Useful input will be used for sure!