Adding an horizontal line programatically

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

    Posted 29 Dec 2010 Link to this post

    Hello,

    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?

    Thanks.
  2. Iva Toteva
    Admin
    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)
    {
        doc1.CaretPosition.MoveToLastPositionInDocument();
     
        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);
     
        doc1.Sections.First.Blocks.Add(table);
     
        //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.
        this.MeasureAndArrangeInDefaultSize(doc1);
    }
     
    private void MeasureAndArrangeInDefaultSize(RadDocument document)
    {
        document.Measure(RadDocument.MAX_DOCUMENT_SIZE);
        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.


    Greetings,
    Iva
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  3. DevCraft banner
Back to Top