Hello all
I have a richtextbox and there is a thread which keeps appending the text to the rtb. I would be selecting a text and when the text gets appended to the control i need to retain the selection. I am able to retain the selection but i am losing the selected text color. The selected text may be in different colors and the new text when getting appended appends with a specific color. So the selected text color is changing to the appended color text.
I need to retain the color of the selected text. For eg. if the selected text contains red color in one line and blue color in one line and appended text is having a color property to blue the the selected text changes to green color and i am losing the original color. I am using .net 2.0
I am writing the following code :
int previousSelectedIndex = this.rtb.SelectionStart;
int selectedLengthText = this.rtb.SelectionLength;
setcolor(color) //--- My own method to set color to the text based on certain condition
this.rtb.AppendText("Hi i am appending text");
this.rtb.AppendText("\n");
this.rtb.SelectionStart = previousSelectedIndex;
this.rtb.SelectionLength = selectedLengthText;
rtb.Focus();
Please help me in fixing this issue.
Regards