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

New Page Event and Layout Control

2 Answers 97 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.
timothy
Top achievements
Rank 1
timothy asked on 17 Oct 2010, 04:38 PM
When the richtextbox is in paged mode is there a way to know when a new page is created.  Also is there anyway to prevent a new page from being created.  My example would be if a user enters too much text for the document size I would like to alert them rather then just creating a new page.  Also is there a way to control pagesize by units like inches, points etc..?

2 Answers, 1 is accepted

Sort by
0
Accepted
Iva Toteva
Telerik team
answered on 20 Oct 2010, 07:22 AM
Hello timothy,

There is no event that is fired when a new page is created. There is, however, a way to find out the current number of pages in the document and compare it to a predefined number.
In your handler of the DocumentContentChanged event of the RadRichTextBox, you can access the number of pages currently in the document and implement your desired behavior. This is an example:
private void radRichTextBox_DocumentContentChanged(object sender, EventArgs e)
        {
           int MAX_PAGES = 1;
           int pages = this.radRichTextBox.Document.DocumentLayoutBox.ChildLayoutBoxes.Count;
           while (pages > MAX_PAGES)
           {
               this.radRichTextBox.Undo();
           }
        }
As soon as you verify that the user has exceeded the limit, you can do whatever you like, e.g. undo the last action, show a warning, etc.

Hopefully that approach to the problem is suitable in your case.

Regards,
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
Accepted
Iva Toteva
Telerik team
answered on 20 Oct 2010, 10:12 AM
Hi timothy,

As it comes to your other question about setting page layout settings using points and inches, you should check the options that Telerik.Windows.Documents.Model.Unit exposes for converting to and from dip.
In a nutshell, you would need something like:
double inches = 3D;
this.radRichTextBox.Document.DefaultPageLayoutSettings.Width = (float) Unit.InchToDip(inches);


Greetings,
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
Tags
RichTextBox
Asked by
timothy
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Share this question
or