We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to control margins in GridPrintDocument

Thread ID:

Created:

Updated:

Platform:

Replies:

65089 Jul 25,2007 01:59 AM Jul 31,2007 04:12 PM Windows Forms 6
loading
Tags: GridControl
Pradeep Kumar
Asked On July 25, 2007 01:59 AM

Hi,

I am using GridPrintDoucment to print the grid which spreads over multiple pages. In the first page I am printing header above the grid. To print the header I adjusted the DefaultPageSettings of the print document in BeginPrint(). On the second page i don't want to print the header and i want to print the grid from the top of the page. How can I achieve it?
It looks like the GridPrintDocument is
calculating the number of rows that fit into a page and size of grid to be printed in the OnBeginPrint(). How can I control the margins in OnPrintPage(), so that I can achieve my requirement.


Thanks
-Pradeep



haneefm [Syncfusion]
Replied On July 25, 2007 01:55 PM

Hi Pradeep,

Here is a KB explaining "How do I print header and footer in a grid on each page?". Please try this and let me know if this helps.
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=62

Best regards,
Haneef

Pradeep Kumar
Replied On July 26, 2007 02:16 AM

Hi Haneef,

Thanks for your reply. The attached sample contains the exact requirement that i want. I modified your sample to print multiple lines of header above the grid in the first page. I am not printing the header from second page so i want to move the grid upwards so that space above the grid can be utilized. How can i achieve it?

FYI: I modified code in C# solution of attached sample.


Thanks
-Pradeep

PrintHeaderFooter0.zip

Pradeep Kumar
Replied On July 30, 2007 07:59 AM

Hi

If there is a problem with attachment sent in with the previous mail, please try with the new attachment, to understand the problem mentioned above. Please come up with a solution as it is an urgent requirement for me.

Thanks
-Pradeep

WindowsApplication1213.zip

haneefm [Syncfusion]
Replied On July 30, 2007 01:52 PM

Hi Pradeep,

You can change the MarginBounds of the print page in a OnPrintPage method. Below are the code that shows you "How to change the MarginBounds in a PrintPage?". Please try the attached sample and let me know if this helps.

protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs ev)
{
if (pageNo != 1)
{
Rectangle MarginBounds = new Rectangle(ev.MarginBounds.X, ev.MarginBounds.Y - 180, ev.MarginBounds.Width, ev.MarginBounds.Height);
PrintPageEventArgs Printarg = new PrintPageEventArgs(ev.Graphics,MarginBounds,ev.PageBounds,ev.PageSettings);
base.OnPrintPage(Printarg);
}
else
base.OnPrintPage(ev);

///You code here ....
}

Sample : WindowsApplication12.zip

Best regards,
Haneef

Pradeep Kumar
Replied On July 31, 2007 08:29 AM

Hi Haneef,

Thanks for your response. The sample send by you works fine. But there is a problem with it. The sample is able to print pages when there are two pages only. If there exists more than two pages it is not printing.

The other problem is on the second page the grid moves up to utilize the header space it is correct. But in the bottom of the page it doesn't occupy till the bottom as it does in the first page. How can i overcome these problems?

Thanks
-Pradeep



WindowsApplication1214.zip

haneefm [Syncfusion]
Replied On July 31, 2007 04:12 PM

Hi Pradeep,

You would have to override the OnPrintPage method and set the HasMorePages property of the PrintPageEventArgs. below is a code snippet

protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs ev)
{
if (pageNo != 1)
{
Rectangle MarginBounds = new Rectangle(ev.MarginBounds.X, ev.MarginBounds.Y - 180, ev.MarginBounds.Width, ev.MarginBounds.Height + 180 * 3);
PrintPageEventArgs Printarg = new PrintPageEventArgs(ev.Graphics, MarginBounds, ev.PageBounds, ev.PageSettings);
base.OnPrintPage(Printarg);
ev.HasMorePages = Printarg.HasMorePages ;
}
else
base.OnPrintPage(ev);
///Your code...
}

Best regards,
Haneef

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;