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

Can't change the PageLayoutSetting

3 Answers 98 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Andrea Ferrari
Top achievements
Rank 1
Andrea Ferrari asked on 28 May 2010, 09:25 AM
Hi,
I need to show some formatted pages on a Book. My customer have seen the Book component and he says: "Wonderful", so now I've to do it.
I've starder creating an Editor (of course my customer wanto to edit/modify the pages) using the RichTextBox wich load and save the pages on the customers database.
One day is gone, but the result is fine.

Now I've to create the Book on a page with dynamic width and hight, so I created a UserControl with a RichTextBox inside, without setting the Height and Width, but setting the Margin.

And now???
I've tryied to change the dimension of the page dynamically with the following method when the RichTextBox is loaded:

    private void editor_Loaded(object sender, RoutedEventArgs e)  
    {  
      RadRichTextBox tb = sender as RadRichTextBox;  
      tb.Document.PageLayoutSettings.Height = controlSize.Height - defaultMargin.Top - defaultMargin.Bottom;  
      tb.Document.PageLayoutSettings.Width = controlSize.Width - defaultMargin.Left - defaultMargin.Right; ;  
      tb.UpdateEditorLayout();  
    }  
 
But, I don't know how to change the left and top margin of the page. Where are the left, top, bottom and right property of the RichTextBox Page?

Thanks a lot and Regards.
Andrea Ferrari

3 Answers, 1 is accepted

Sort by
0
Mike
Telerik team
answered on 31 May 2010, 07:52 AM
Hello Andrea Ferrari,

To change the default PageMargins of a document you can use the property RadDocument.SectionDefaultPageMargin. Note that when a document in stored in Xaml format it contains information about PageMargins. In this case, after loading document you may need to set the page margin of the first Section in the document:
RadDocument.Sections.First.PageMargin

Kind regards,
Mike
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
Jeffrey
Top achievements
Rank 1
answered on 14 May 2018, 03:35 PM
Specifically how do you change it using RadDocument.SectionDefaultPageMargin as you suggest? If I wanted .5" margins all around what would that look like in code?
0
Georgi
Telerik team
answered on 16 May 2018, 03:44 PM
Hi Jeffrey,

To set the SectionDefaultPageMargin property to 0.5 inches, you will need to first convert the value to pixels, as they are used as the measurement unit by the API. This could be easily achieved using the Unit class:
double marginAll = 0.5;
this.radRichTextBox.Document.SectionDefaultPageMargin = new Padding(Convert.ToInt32(Unit.InchToDip(marginAll)));

If the changes should be applied to the document after it has been loaded in the editor, you can call the RadRichTextBox.ChangeSectionPageMargin() method:
private void radRichTextBox_Loaded(object sender, RoutedEventArgs e)
{
    double marginAll = 0.5;
    this.radRichTextBox.ChangeSectionPageMargin(new Padding(Convert.ToInt32(Unit.InchToDip(marginAll))));
}

I hope this helps.

Regards,
Georgi
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
RichTextBox
Asked by
Andrea Ferrari
Top achievements
Rank 1
Answers by
Mike
Telerik team
Jeffrey
Top achievements
Rank 1
Georgi
Telerik team
Share this question
or