Click here to Skip to main content
12,746,681 members (28,580 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#
My page margins top and bottom are not what is entered in Page Setup dialogue box. The left, right margins are ok, but the top, bottom margins are all over the place.
Thanks in advance for your help. I am using the page setup tool from the visual studio toolbox.

This one works ok.
MypageSetupDialog.PageSettings.Margins = new Margins(40, 40, 40, 40);

But when I change to this
MypageSetupDialog.PageSettings.Margins = new Margins(100, 100, 100, 100);
The bottom margin is more than 1 inch.
Posted 23-Jun-12 14:43pm
Updated 24-Jun-12 4:11am
Sandeep Mewara 24-Jun-12 4:32am
Not clear if you are talking of web or winforms here.
Al Yambo 24-Jun-12 9:15am
Thank you for your inquiry. This is a winform or windows app.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

use this in body

<body bottommargin="10" rightmargin="10" leftmargin="10" topmargin="10">
Sandeep Mewara 24-Jun-12 4:31am
In Winforms?

Not sure if OP asking for web or winforms. If web then ok.
Al Yambo 24-Jun-12 9:14am
Thank you for your response. This is a winform or windows app.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

//In the DrawRows method here is the code that checks for end of page

// Checking if the CurrentY is exceeds the page boundries
// If so then exit the function and returning true meaning another
// PagePrint action is required
if ((int)CurrentY > (PageHeight - TopMargin - BottomMargin))
return true;

//should be
if ((int)CurrentY > (PageHeight - BottomMargin))
// otherwise the bottom margin is doubled (if the same as top margin)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170215.1 | Last Updated 16 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100