Setting the Page Margins
To set the page margins, assign a value to the page settings for the margin. This can be set either in the designer or in code.
In the Designer
1. Locate the PageSettings property for C1PrintDocument in the Properties window and click the ellipsis button next to it. This will open the Page Setup dialog box.
2. In the Margins area, enter 2 in the Left, Top, Right, and Bottom boxes to set the margins to 2 inches.
3. Click OK to close the Page Setup dialog box.
In Code
Add the following code to the Form_Load event to set the page margins to 2 inches:
' Set the page margins in the default unit (inches).
Me.C1PrintDocument1.PageSettings.Margins.Top = 200
Me.C1PrintDocument1.PageSettings.Margins.Bottom = 200
Me.C1PrintDocument1.PageSettings.Margins.Left = 200
Me.C1PrintDocument1.PageSettings.Margins.Right = 200
• C#
// Set the page margins in the default unit (inches).
this.c1PrintDocument1.PageSettings.Margins.Top = 200;
this.c1PrintDocument1.PageSettings.Margins.Bottom = 200;
this.c1PrintDocument1.PageSettings.Margins.Left = 200;
this.c1PrintDocument1.PageSettings.Margins.Right = 200;
This topic illustrates the following:
The page margins will be 2 inches on all sides.
|