This question is locked. New answers and comments are not allowed.
Hello!
I have a problem with RichTextBox. I need to create RadDocument for RichText in code. It contains tables. If I add InlineUIContainers to table cells, RichText doesn't behave properly after scrolling - it moves table cells content to random places in Document.
Where is my mistake?
I have a problem with RichTextBox. I need to create RadDocument for RichText in code. It contains tables. If I add InlineUIContainers to table cells, RichText doesn't behave properly after scrolling - it moves table cells content to random places in Document.
Where is my mistake?
public void createRadDocument() { var BaseRadDocument = new RadDocument(); BaseRadDocument.LayoutMode = DocumentLayoutMode.Flow; BaseRadDocument.ParagraphDefaultSpacingAfter = 0; BaseRadDocument.PageViewMargin = new SizeF(0, 0); BaseRadDocument.SectionDefaultPageMargin = new Padding(0); Section section = new Section(); CreateSection(0, section); BaseRadDocument.Sections.Add(section); rich.Document = BaseRadDocument; } public void CreateSection(int level, Section section) { for (int i = 0; i < 15; i++) { createDocElementsForNewItem(i, section); } } private void createDocElementsForNewItem(int level, Section section) { int indent = 20 * level; var cell_11 = new TableCell(); cell_11.PreferredWidth = new TableWidthUnit(80 + indent); var cell_12 = new TableCell(); Paragraph paragraph_113 = new Paragraph(); Size firstSize = new Size(100, 20); TextBlock start = new TextBlock(); start.Text = String.Format("start|{0}", level); start.Tag = String.Format("start|{0}", level); InlineUIContainer containerFirst = new InlineUIContainer(start, firstSize); paragraph_113.Inlines.Add(containerFirst); Paragraph paragraph_111 = new Paragraph(); paragraph_111.LeftIndent = indent; paragraph_111.SpacingAfter = 0; paragraph_111.SpacingBefore = 0; paragraph_111.TextAlignment = RadTextAlignment.Right; Span date = new Span(String.Format("{0} ", DateTime.UtcNow.ToShortDateString())); date.FontSize = 12; date.ForeColor = new Color() { A = 0xff, B = 0x68, G = 0x68, R = 0x68 }; date.FontFamily = new FontFamily("Calibri"); paragraph_111.Inlines.Add(date); Paragraph paragraph_112 = new Paragraph(); paragraph_112.LeftIndent = indent; paragraph_112.SpacingAfter = 0; paragraph_112.SpacingBefore = 0; paragraph_112.TextAlignment = RadTextAlignment.Right; Span time = new Span(String.Format("{0} ", DateTime.UtcNow.ToLongTimeString())); time.FontSize = 12; time.ForeColor = new Color() { A = 0xff, B = 0x68, G = 0x68, R = 0x68 }; time.FontFamily = new FontFamily("Calibri"); paragraph_112.Inlines.Add(time); paragraph_112.LeftIndent = indent; for (int j = 0; j < 5; j++) { var span = new Span(String.Format("Текст {0}", j)); var par = new Paragraph(); par.Inlines.Add(span); cell_12.Blocks.Add(par); } Paragraph paragraph_12n = new Paragraph(); Size lastSize = new Size(100, 20); TextBlock finish = new TextBlock(); finish.Text = String.Format("end|{0}|{1}", level, indent); finish.Tag = String.Format("end|{0}|{1}", level, indent); InlineUIContainer containerLast = new InlineUIContainer(finish, lastSize); paragraph_12n.Inlines.Add(containerLast); cell_11.Blocks.Add(paragraph_113); cell_11.Blocks.AddAfter(paragraph_113, paragraph_111); cell_11.Blocks.AddAfter(paragraph_111, paragraph_112); cell_12.Blocks.Add(paragraph_12n); var row_1 = new TableRow(); row_1.Cells.Add(cell_11); row_1.Cells.AddAfter(cell_11, cell_12); Table table = new Table(); table.Rows.Add(row_1); section.Blocks.Add(table); section.Blocks.Add(new Paragraph()); } private void UserControl_Loaded(object sender, RoutedEventArgs e) { createRadDocument(); }