easy way to replace the selected text?

5 posts, 0 answers
  1. Sopan
    Sopan avatar
    34 posts
    Member since:
    May 2012

    Posted 26 Aug 2013 Link to this post

    Hi,

    any easy way to replace the selected text with new style ?
  2. Petya
    Admin
    Petya avatar
    975 posts

    Posted 29 Aug 2013 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Sopan
    Sopan avatar
    34 posts
    Member since:
    May 2012

    Posted 29 Aug 2013 Link to this post

    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.
  5. Petya
    Admin
    Petya avatar
    975 posts

    Posted 02 Sep 2013 Link to this post

    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 >>
  6. Sopan
    Sopan avatar
    34 posts
    Member since:
    May 2012

    Posted 02 Sep 2013 Link to this post

    Thank you very much
Back to Top
UI for WPF is Visual Studio 2017 Ready