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

[Solved] RichTextBox with Tables scrolling

4 Answers 142 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kate
Top achievements
Rank 1
Kate asked on 13 Nov 2010, 01:00 PM
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?

 

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();
       }

 

 

4 Answers, 1 is accepted

Sort by
0
Ivailo Karamanolev
Telerik team
answered on 15 Nov 2010, 09:35 AM
Hello Kate,

I have just tested the code you posted against the official Q3 release and found no problems whatsoever. Please confirm you are using the latest versions of all relevant assemblies and try to clean/rebuild your project. If these issues persist, please send us a demo project which exhibits these problems so we can assist you further.

Sincerely yours,
Ivailo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Iva Toteva
Telerik team
answered on 15 Nov 2010, 10:00 AM
Hello Kate,

We managed to reproduce the issue. We will see into is and will get back to you soon. 

Best wishes,
Iva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ivailo Karamanolev
Telerik team
answered on 17 Nov 2010, 10:17 AM
Hello Kate,

Thanks for the bug report. We discovered where the issue is and fixed it. This will be visible in the next LIB coming at the end of this week. Until then, you can workaround this issue by wrapping the TextBlocks in Grids (i.e. add the TextBlock to a Grid's children and then use the Grid inside the InlineUIContainer).

Regards,
Ivailo
the Telerik team
See What's New in RadControls for Silverlight in Q3 2010 on Tuesday, November 16, 2010 11:00 AM - 12:00 PM EST or 10:00 PM - 11:00 PM EST: Register here>>
0
Kate
Top achievements
Rank 1
answered on 17 Nov 2010, 10:36 AM
Thanks a lot! We are waiting for new changes.
Tags
RichTextBox
Asked by
Kate
Top achievements
Rank 1
Answers by
Ivailo Karamanolev
Telerik team
Iva Toteva
Telerik team
Kate
Top achievements
Rank 1
Share this question
or