Why RichTextBox lose format after appending new String?

Posted by user556526 on Stack Overflow See other posts from Stack Overflow or by user556526
Published on 2010-12-28T22:44:56Z Indexed on 2010/12/28 22:53 UTC
Read the original article Hit count: 178

Filed under:

Hi guys

I have aproblem with rich text box string color:

I have the richtexbox that user type a message in it. I mark up each word that exist in my dictionary. I use this code for it:

  this.inputTextAreaRtb.Text=this.inputTextAreaRtb.Text.Remove(startCoordinate, endCoordinate - startCoordinate);

  this.inputTextAreaRtb.SelectionStart = this.inputTextAreaRtb.Text.Length;
 this.inputTextAreaRtb.SelectionLength = 0;
  this.inputTextAreaRtb.SelectionFont = new System.Drawing.Font(
  "David",
12, FontStyle.Underline);   
   this.inputTextAreaRtb.SelectionColor = Color.DarkBlue;                                             
   this.inputTextAreaRtb.AppendText(_word);
  this.inputTextAreaRtb.SelectionColor = this.inputTextAreaRtb.ForeColor;
  this.inputTextAreaRtb.SelectionFont = new System.Drawing.Font(
   "David",
 12, FontStyle.Regular);      

But each time if I already marked up a word a loose formatting of words that already formatted.

Any ideas of this problem?

© Stack Overflow or respective owner

Related posts about c#