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

[Solved] AddPageNumber Dynamically

2 Answers 72 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.
aubrey
Top achievements
Rank 1
aubrey asked on 15 Jul 2011, 07:19 AM
Good day Telerik Team,

Am just wondering if how i can set page number in every page of the RadRichtextbox dynamically..  


Thanks,
Aubrey :)

2 Answers, 1 is accepted

Sort by
0
Accepted
Iva Toteva
Telerik team
answered on 20 Jul 2011, 04:57 PM
Hello Aubrey,

Here is how you can programmatically insert a PageNumber field in the Header of the document:

private void InsertPageNumberInHeader()
{
    Header header = new Header();
    RadDocument document = new RadDocument();
    Section section = new Section();
    Paragraph paragraph = new Paragraph();
    paragraph.TextAlignment = RadTextAlignment.Right;
 
    FieldRangeStart fieldStart = new FieldRangeStart();
    FieldRangeEnd fieldEnd = new FieldRangeEnd();
     
    fieldEnd.PairWithStart(fieldStart);
    fieldStart.Field = new PageField();
    fieldStart.Field.DisplayMode = FieldDisplayMode.Result;
 
    paragraph.Children.Add(fieldStart);
    paragraph.Children.Add(fieldEnd);
    section.Children.Add(paragraph);
    document.Sections.Add(section);
    header.Body = document;
 
    this.richTextBox.HeaderFooterUIContext.UpdateHeader(this.richTextBox.Document.Sections.First, HeaderFooterType.Default, header);
}
All the best,
Iva
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
aubrey
Top achievements
Rank 1
answered on 22 Jul 2011, 06:13 AM
Hi Iva,

thanks for the reply! I got it now. :)

thanks,
Aubrey :) 
Tags
RichTextBox
Asked by
aubrey
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
aubrey
Top achievements
Rank 1
Share this question
or