This is a migrated thread and some comments may be shown as answers.

Change typing color in RichTextBox

2 Answers 256 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Joseph
Top achievements
Rank 1
Joseph asked on 31 Jan 2011, 01:19 PM
Hi guys,

When I insert a span with a foregroundcolor set to red and start typing immedialty after this element, the typing color becomes red instead of Black. How can I reset typing color to black ?

Thanks.

2 Answers, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 01 Feb 2011, 06:01 PM
Hi Joseph,

 You can do that as follows:

//Insert Span
 this.radRichTextBox.ChangeTextForeColor(Colors.Black);
 this.radRichTextBox.Focus();

When you set different style settings to a part of the document, one or several new spans are created. However, when you change the fore color when you have not selected anything a new span is not created until you insert some text and if you do not focus the rich text box explicitly, the next time it receives focus, it will treat the fore color of the last span as the current editing style, which is the expected behavior. Thus, if you want to change the editing style after the red span, you would have to insert a new span (containing an interval for instance) having Black as text fore color, or focus the rich text box right after invoking the method (as shown in the snippet).
If you have any other questions, do not hesitate to contact us again.

Kind regards,
Iva
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Joseph
Top achievements
Rank 1
answered on 02 Feb 2011, 08:59 AM
Thanks for the heads up!
Tags
RichTextBox
Asked by
Joseph
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Joseph
Top achievements
Rank 1
Share this question
or