Defining style with capital letters

5 posts, 0 answers
  1. Shahrzade
    Shahrzade avatar
    8 posts
    Member since:
    Feb 2016

    Posted 13 Apr Link to this post

    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.

  2. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 14 Apr Link to this post

    Hello Shahrzade,

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Shahrzade
    Shahrzade avatar
    8 posts
    Member since:
    Feb 2016

    Posted 14 Apr in reply to Shahrzade Link to this post

    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.

  5. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 14 Apr Link to this post

    Hello Shahrzade,

    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.
  6. Shahrzade
    Shahrzade avatar
    8 posts
    Member since:
    Feb 2016

    Posted 15 Apr in reply to Dess Link to this post

    Thanks a lot for the info.

    Shahrzade.

Back to Top
UI for WinForms is Visual Studio 2017 Ready