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

easy way to replace the selected text?

4 Answers 220 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Sopan
Top achievements
Rank 1
Sopan asked on 26 Aug 2013, 12:51 PM
Hi,

any easy way to replace the selected text with new style ?

4 Answers, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 29 Aug 2013, 11:15 AM
Hi Sopan,

I am afraid I am not sure what you mean - are you trying to replace the selected text, to change its style or both?

Generally, to replace the current selection is fairly simple - you just have to call one of the Insert~() methods of RadRichTextBox. 

When it comes to formatting part of a document, I suggest you review this article which explains the concept of Styles in RadRichTextBox. If you are just looking for a way to change one of the properties of the selected text, for example it's ForeColor, you can simply call the respective method of RadRichTextBox:
this.radRichTextBox.ChangeTextForeColor(Colors.Aqua);

I hope this is helpful! Let us know if you have additional comments or questions.

Regards,
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Sopan
Top achievements
Rank 1
answered on 29 Aug 2013, 12:13 PM
Hi Petya thanks for replayed

Suppose I have entered text to RadRichTextBox as Following with all default text formatting

This problem is very complex.

from above text "problem" word selected, now I want to replace this word in same place with fontweights as bold and color also so that it look like as following

This problem is very complex.

to perform this operation, I want any simple way.
0
Petya
Telerik team
answered on 02 Sep 2013, 12:46 PM
Hi Sopan,

As I said in my previous reply, in order to replace the current selection you can simply call one of the Insert~() methods of RadRichTextBox.

However, what I believe will better suit your needs in this case is to only change the formatting with the respective methods of RadRichTextBox. The control provides API that corresponds to its commands and operates over the current selection. For example, this is how you can make the selection bold and with color Colors.Aqua:
this.radRichTextBox.ToggleBold();
this.radRichTextBox.ChangeTextForeColor(Colors.Aqua);

Let us know if there is anything unclear.

Regards,
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Sopan
Top achievements
Rank 1
answered on 03 Sep 2013, 04:12 AM
Thank you very much
Tags
RichTextBox
Asked by
Sopan
Top achievements
Rank 1
Answers by
Petya
Telerik team
Sopan
Top achievements
Rank 1
Share this question
or