How to control margins in GridPrintDocument
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
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
SIGN IN To post a reply.
6 Replies
HA
haneefm
Syncfusion Team
July 25, 2007 05:55 PM UTC
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
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
PK
Pradeep Kumar
July 26, 2007 06:16 AM UTC
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
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
PK
Pradeep Kumar
July 30, 2007 11:59 AM UTC
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
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
HA
haneefm
Syncfusion Team
July 30, 2007 05:52 PM UTC
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
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
PK
Pradeep Kumar
July 31, 2007 12:29 PM UTC
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
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
HA
haneefm
Syncfusion Team
July 31, 2007 08:12 PM UTC
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
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
SIGN IN To post a reply.
- 6 Replies
- 2 Participants
-
PK Pradeep Kumar
- Jul 25, 2007 05:59 AM UTC
- Jul 31, 2007 08:12 PM UTC