   [.net] Changing color in RichTextBox
  I am using a Rich Text Box as a box as a console. I want to add a line, and the color changes depending on the type of message. The message gets added fine, but the color is not set. Any ideas?   public void print(string text, MessageType type)   {  // Set font color depending on the message type  switch (type)  { case MessageType.MESSAGE_ERROR:this.tbConsoleBox.SelectionColor = System.Drawing.Color.Red;break; case MessageType.MESSAGE_DEBUG:this.tbConsoleBox.SelectionColor = System.Drawing.Color.Blue;break; case MessageType.MESSAGE_NORMAL:this.tbConsoleBox.SelectionColor = System.Drawing.Color.Black;break; default:this.tbConsoleBox.SelectionColor = System.Drawing.Color.Black;break;  }    // Add the new line  tbConsoleBox.Text += text + Environment.NewLine;   }
  By setting the Text property you are destroying the selection and thereby the colour you've just set up. Try setting SelectedText instead, to the text you wish to add only.   