We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

sfRichTextBoxAdv how to set selection to all caps etc.

Thread ID:

Created:

Updated:

Platform:

Replies:

132564 Sep 8,2017 10:31 AM Sep 11,2017 01:53 AM WPF 1
loading
Tags: SfRichTextBoxAdv
Chris Devol
Asked On September 8, 2017 10:31 AM

I want to be able to set the selected text to all caps, small caps, and all lowercase, in code-behind. The standard wpf RichTextBox allows this by setting the CharacterCasing dependencyproperty. How to do this in the syncfusion version? (using code-behind).

Arumuga Perumal S [Syncfusion]
Replied On September 11, 2017 01:53 AM

Hi Chris,

Thank you for contacting Syncfusion support.

Currently our WPF SfRichTextBoxAdv does not provide support for character casing property. We have already logged this requirement as feature request. We will implement this feature in any of our upcoming releases. We usually have an interval of at least three months between releases. The feature implementation would also greatly depend on the factors such as product design, code compatibility and complexity. We request you to visit our website periodically for feature related updates.

However, you can replace the selected text to all caps or lower case using Selection.InsertText() API. Using this API will convert the replaced text to single formatting even though the selected text contains different formatting. Also the text will be preserved in converted case on exporting. Kindly refer the sample code below.

C#

 
/// <summary> 
/// Converts the casing of selected text in SfRichTextBoxAdv. 
/// </summary> 
/// <param name="isLower">Specifies whether the text to be converted in lower case.</param> 
public void ConvertCase(bool isLower) 
{ 
    // Gets the selected text. 
    string text = richTextBoxAdv.Selection.Text; 
    // Converts the casing of selected text. 
    string replaceText = isLower ? text.ToLower() : text.ToUpper(); 
    if (!text.Equals(replaceText)) 
    { 
        // Store the current selection positions. 
        string start = richTextBoxAdv.Selection.Start.GetHierarchicalIndex; 
        string end = richTextBoxAdv.Selection.End.GetHierarchicalIndex; 
        // Replace the text to converted casing. 
        richTextBoxAdv.Selection.InsertText(replaceText); 
        // Restore the selection positions. 
        richTextBoxAdv.Selection.Select(richTextBoxAdv.Document.GetTextPosition(start), 
            richTextBoxAdv.Document.GetTextPosition(end)); 
    } 
} 
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;