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

Defining style with capital letters

4 Answers 83 Views
RichTextEditor
This is a migrated thread and some comments may be shown as answers.
Shahrzade
Top achievements
Rank 1
Shahrzade asked on 13 Apr 2016, 01:23 PM

Hi

I have changed a heading-style in a RadDocument. I also want that the letters in the header be in upper case, i.e., HEADER instead of Header. How can it be done?

thanks,

Shahrzade.

4 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 14 Apr 2016, 06:31 AM
Hello ,

Thank you for writing.

Here is a sample code snippet demonstrating how to make the header text with capital letters:
public Form1()
{
    InitializeComponent();
    this.radRichTextEditor1.Text = "Header" + Environment.NewLine + "Sample text";
}
 
private void radButton1_Click(object sender, EventArgs e)
{
    string headerText = "Header";
    Telerik.WinForms.Documents.TextSearch.DocumentTextSearch search = new DocumentTextSearch(this.radRichTextEditor1.Document);
    IEnumerable<TextRange> foundRanges = search.FindAll(headerText);
    if (headerText != string.Empty)
    {
        foreach (var textRange in foundRanges)
        {
            this.radRichTextEditor1.Document.Selection.AddSelectionStart(textRange.StartPosition);
            this.radRichTextEditor1.Document.Selection.AddSelectionEnd(textRange.EndPosition);
            string selectedText = this.radRichTextEditor1.Document.Selection.GetSelectedText(); 
 
            this.radRichTextEditor1.ChangeFontSize(22);
             
            this.radRichTextEditor1.ToggleBold();
            this.radRichTextEditor1.ToggleItalic();
            this.radRichTextEditor1.Insert(selectedText.ToUpper());
        }
    }
}

I hope this information helps. Should you have further questions I would be glad to help.

 Regards,
Dess
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Shahrzade
Top achievements
Rank 1
answered on 14 Apr 2016, 09:18 AM

Hi,

What I want to do is to define a StyleDefinition that has "upper case" as its property.

I have a RadRichTextEditor and I have  customized one of the styles as follows (document is MyRadRichTextEditor.Document):

string heading1StyleId = RadDocumentDefaultStyles.GetHeadingStyleNameByIndex(1);
document.StyleRepository.GetValueOrNull(heading1StyleId).SpanProperties.FontFamily = new Telerik.WinControls.RichTextEditor.UI.FontFamily("Arial");
document.StyleRepository.GetValueOrNull(heading1StyleId).SpanProperties.FontSize = Unit.PointToDip(16);
document.StyleRepository.GetValueOrNull(heading1StyleId).SpanProperties.ForeColor = Colors.Black;
document.StyleRepository.GetValueOrNull(heading1StyleId).ParagraphProperties.Background = Colors.White;
document.StyleRepository.GetValueOrNull(heading1StyleId).ParagraphProperties.SpacingBefore = 2.0;

And I want to define that the header, when choosing this header style, must be all in upper case.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 14 Apr 2016, 10:35 AM
Hello ,

Thank you for writing back. 

Currently, RadRichTextEditor does not support functionality to change the selected text to lower/upper case. However, it is a reasonable request. I have logged it in our feedback portal. You can track its progress, subscribe for status changes and add your vote/comment to it on the following link - feedback item.

I have also updated your Telerik points.

I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Shahrzade
Top achievements
Rank 1
answered on 15 Apr 2016, 08:03 AM

Thanks a lot for the info.

Shahrzade.

Tags
RichTextEditor
Asked by
Shahrzade
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Shahrzade
Top achievements
Rank 1
Share this question
or