Adding an horizontal line programatically

2 posts, 0 answers
  1. Daní
    Daní avatar
    314 posts
    Member since:
    Feb 2008

    Posted 29 Dec 2010 Link to this post


    I'm trying to add an horizontal line programtically to a RichTextBox with no success. I've tried to add an InlinieUIContainer with a path and a line as UIElement to a paragraph with no result. Can anyone help me?

  2. Iva Toteva
    Iva Toteva avatar
    1319 posts

    Posted 03 Jan 2011 Link to this post

    Hello Daní,

     InlineUIContainers are not shown, unless you set their Height and Width explicitly. If you want to avoid the necessity of calculating the height and width of the line you are about to insert, you can simply insert a table like we advised you in the support ticket you opened:

    private void AddTableAsSeparator(RadDocument doc1)
        Table table = new Table(1, 1);
        table.Borders.All = new Telerik.Windows.Documents.Model.Border(1, BorderStyle.Single, Colors.Transparent);
        table.Borders.Bottom = new Telerik.Windows.Documents.Model.Border(1, BorderStyle.Single, Colors.Black);
        //You need to measure and arrange the document after manipulating its structure through the Blocks, Inlines, Children, etc properties if you want to use the format providers directly. If you are showing the document in a RadRichTextBox, you should call the UpdateEditorLayout() method on it.
    private void MeasureAndArrangeInDefaultSize(RadDocument document)
        document.Arrange(new RectangleF(PointF.Empty, document.DesiredSize));
    This will work in both Flow and Paged layout mode, on resize of the window and other cases where fixed Height and Width might be a setback.
    Note that we have introduced support for borders of different colors after Q3 and you should upgrade to the version in the latest internal builds in order to use them.

    If you have other questions, do not hesitate to contact us again.

    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
Back to Top