title: How to extend a RichTextbox coloring function to color parts of strings?
body: <pre><code>private void ColorRichTextbox(RichTextBox box, string text, Color color)
  {
      int length = MyRichTextBox.TextLength;
      if (!string.IsNullOrWhiteSpace(MyRichTextBox.Text))
      {
          MyRichTextBox.AppendText(&quot;\r\n&quot; + text);
      }
      else
      {
          MyRichTextBox.AppendText(text);
      }
      MyRichTextBox.SelectionStart = length;
      MyRichTextBox.SelectionLength = text.Length;
      MyRichTextBox.SelectionColor = color;
  }
  </code></pre>
  <p>Usage:</p>
  <pre><code>ColorRichTextbox(MyRichTextBox,
                      &quot;This is example : &quot; + DateTime.Now, Color.Red);
  </code></pre>
  <p>The result is one line in red consisting of &quot;This is example : &quot; with the <code>DateTime.Now</code> part. Is there a way to make for example the part &quot;This is example : &quot; in white color and <code>DateTime.Now</code> to be in red?</p>