How to change selection color of RadRichTextBox

7 posts, 0 answers
  1. Cyrus
    Cyrus avatar
    9 posts
    Member since:
    Jan 2011

    Posted 06 Aug 2014 Link to this post

    Hi There,

    I am having issues with the RadRichTextBox when one suddenly changse the font color to white or same color as the background and when you select the word or sentence once can't see the highlighted word or sentence :( you cant really change the background color since you can choose to type in any color. Is there a way to fix the issue of selection where you can see the word after it is selected




  2. Cyrus
    Cyrus avatar
    9 posts
    Member since:
    Jan 2011

    Posted 07 Aug 2014 in reply to Cyrus Link to this post

    Attached is the image of the issue
  3. DevCraft banner
  4. Mihail
    Admin
    Mihail avatar
    192 posts

    Posted 11 Aug 2014 Link to this post

    Hello Cyrus,

    The described behavior is inevitable when the end user have control over the foreground and the background colors. You can observe the same behavior in MS Word. After all the end user is responsible for the structure and design of its documents. 

    However if your requirements are to eliminate this issue you could use RadColorPicker with customized colors to control what colors can be set as foreground and background. Here is the link to the help section for RadColorPicker.

    If you have further questions feel free to contact us again.

    Regards,
    Mihail
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  5. Cyrus
    Cyrus avatar
    9 posts
    Member since:
    Jan 2011

    Posted 12 Aug 2014 in reply to Mihail Link to this post

    Hi Mihail,

    Thanks for the reply, is there a way/method/event to check what foreground or font color the user has picked and set the background of the RadRichTextBox to a different color according to that?
  6. Mihail
    Admin
    Mihail avatar
    192 posts

    Posted 13 Aug 2014 Link to this post

    Hello Cyrus,

     Theoretically you could subscribe to the SelectedColorChanged event of the color picker and depending of the color of the span where the caret position is at this point to change the background of RadRichTextBox.

    However I wouldn't recommend you to do it. Because in most cases there is more than one span in the document. And if the end user set different forecolor to each span, changing the background of RadRichTextBox each time won't really help.

    Regards,
    Mihail
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  7. bhargava
    bhargava avatar
    14 posts
    Member since:
    Feb 2015

    Posted 10 Mar 2015 Link to this post

    Hi Mihail,
    I am having issue but in a different context. I set the font  , font size, color and pass it in a session and set the values to RadRichtextbox font.
    Everything works fine when I first start writing on the richtextbox .but,when I submit the text and try to write again font ,font size works except for the color which changes black.


    HTML:
    "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>Untitled</title><style type=\"text/css\">\r\np { margin-top: 0px;margin-bottom: 0px;line-height: 1.15; } \r\nbody { font-family: 'Comic Sans MS';font-style: Normal;font-weight: normal;font-size: 18.6666660308838px;color: #A52A2A; } \r\n.Normal { telerik-style-type: paragraph;telerik-style-name: Normal;border-collapse: collapse; } \r\n.TableNormal { telerik-style-type: table;telerik-style-name: TableNormal;border-collapse: collapse; } \r\n.s_DF0FDE4 { telerik-style-type: local;color: #A52A2A; } </style></head><body><p class=\"Normal \"><span class=\"s_DF0FDE4\">s</span></p></body></html>"
  8. Mihail
    Admin
    Mihail avatar
    192 posts

    Posted 12 Mar 2015 Link to this post

    Hello Bhargava Ram,

    From what I understand you are trying to set styling to RadRichTextBox document. This could be done with two different approaches:

    1) Setting the required styling in XAML: 
    <telerik:RadRichTextBox x:Name="radRichTextBox" FontSize="44" FontFamily="Comic Sans MS" DocumentInheritsDefaultStyleSettings="True" />
    More information about approach you could read in this help article. The drawback is that you have access to limited amount of properties to set.

    2) Setting the required styling in code behind on RadRichTextBox load and document changed events:
    private void SetMyStyleProperties()
    {
        this.radRichTextBox.DocumentInheritsDefaultStyleSettings = false;
        this.radRichTextBox.Document.Style.SpanProperties.FontFamily = new FontFamily("Comic Sans MS");
        this.radRichTextBox.Document.Style.SpanProperties.FontSize = Unit.PointToDip(22);
        this.radRichTextBox.Document.Style.SpanProperties.ForeColor = Colors.Red;
    }
     
    private void radRichTextBox_Loaded(object sender, RoutedEventArgs e)
    {
        this.SetMyStyleProperties();
    }
     
    private void radRichTextBox_DocumentChanged(object sender, EventArgs e)
    {
        this.SetMyStyleProperties();
    }

    The benefit of this approach is that you could set any of the style properties which RadDocument supports.

    In case I misunderstand your overall goal or you have further questions do not hesitate to contact us again.

    Regards,
    Mihail
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
DevCraft banner