private void pd_PrintPage(object sender,System.Drawing.Printing.PrintPageEventArgs e) { Rectangle bounds=e.MarginBounds; //new Rectangle(50,40,800,1035);//Some printers can handle up to 1042 Graphics g=e.Graphics; string text; Font headingFont=new Font("Arial",13,FontStyle.Bold); Font subHeadingFont=new Font("Arial",10,FontStyle.Bold); int yPos=bounds.Top; int center=bounds.X+bounds.Width/2; #region printHeading if(!headingPrinted) { text=Lan.g(this,"Confirmation List"); g.DrawString(text,headingFont,Brushes.Black,center-g.MeasureString(text,headingFont).Width/2,yPos); yPos+=(int)g.MeasureString(text,headingFont).Height; text=textDateFrom.Text+" "+Lan.g(this,"to")+" "+textDateTo.Text; g.DrawString(text,subHeadingFont,Brushes.Black,center-g.MeasureString(text,subHeadingFont).Width/2,yPos); yPos+=20; headingPrinted=true; headingPrintH=yPos; } #endregion yPos=grid.PrintPage(g,pagesPrinted,bounds,headingPrintH); pagesPrinted++; if(yPos==-1) { e.HasMorePages=true; } else { e.HasMorePages=false; } g.Dispose(); }
private void pd2_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { Rectangle bounds = new Rectangle(50, 40, 800, 1035); //Some printers can handle up to 1042 Graphics g = e.Graphics; string text; Font headingFont = new Font("Arial", 13, FontStyle.Bold); Font subHeadingFont = new Font("Arial", 10, FontStyle.Bold); int yPos = bounds.Top; int center = bounds.X + bounds.Width / 2; #region printHeading if (!headingPrinted) { text = AccountCur.Description + " (" + Lan.g("enumAccountType", AccountCur.AcctType.ToString()) + ")"; g.DrawString(text, headingFont, Brushes.Black, center - g.MeasureString(text, headingFont).Width / 2, yPos); yPos += (int)g.MeasureString(text, headingFont).Height; text = DateTime.Today.ToShortDateString(); g.DrawString(text, subHeadingFont, Brushes.Black, center - g.MeasureString(text, subHeadingFont).Width / 2, yPos); yPos += 20; headingPrinted = true; headingPrintH = yPos; } #endregion yPos = gridMain.PrintPage(g, pagesPrinted, bounds, headingPrintH); pagesPrinted++; if (yPos == -1) { e.HasMorePages = true; } else { e.HasMorePages = false; } g.Dispose(); }