New Page Event and Layout Control

3 posts, 2 answers
  1. timothy
    timothy avatar
    2 posts
    Member since:
    Nov 2008

    Posted 17 Oct 2010 Link to this post

    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. Answer
    Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 20 Oct 2010 Link to this post

    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
  3. Answer
    Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 20 Oct 2010 Link to this post

    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
Back to Top