This is a migrated thread and some comments may be shown as answers.

Adding an horizontal line programatically

1 Answer 197 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Daní
Top achievements
Rank 1
Daní asked on 29 Dec 2010, 05:03 PM
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.

1 Answer, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 03 Jan 2011, 09:33 AM
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
Tags
RichTextBox
Asked by
Daní
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Share this question
or