How can i add lines with different background colors?

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

    Posted 07 Sep 2012 Link to this post


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

  2. Stefan
    Stefan avatar
    2908 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:

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