How can i add lines with different background colors?

2 posts, 0 answers
  1. TOMISLAV
    TOMISLAV avatar
    1 posts
    Member since:
    Oct 2011

    Posted 07 Sep 2012 Link to this post

    Hi,

    how kann i add lines of text with different background colors to the radrichtextbox ?

  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 10 Sep 2012 Link to this post

    Hello Tomislav,

    Thank you for writing.

    Here is a method that allows you to specify the desired colors and insert the text:
    private void InsertTextInDocument(string textToInsert, Color lineColor)
    {
        StyleDefinition style = new StyleDefinition();
        style.SetPropertyValue(Span.FontFamilyProperty, "Comic Sans MS");
        style.SetPropertyValue(Span.FontSizeProperty, Unit.PointToDip(16));
        style.SetPropertyValue(Span.ForeColorProperty, Color.Yellow);
        style.SetPropertyValue(Span.HighlightColorProperty, lineColor);
        this.radRichTextBox1.Document.Insert(textToInsert, style);
    }

    More information about the customization abilities of a Span is available here: http://www.telerik.com/help/winforms/richtextbox-features-document-elements-span.html.

    I hope that the provided information addresses your question.
     
    Kind regards,
    Stefan
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top