Esempio n. 1
0
        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 = Lan.g(this, "Claim History");
                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
            int totalPages = gridHistory.GetNumberOfPages(bounds, headingPrintH);
            yPos = gridHistory.PrintPage(g, pagesPrinted, bounds, headingPrintH);
            pagesPrinted++;
            if (pagesPrinted < totalPages)
            {
                e.HasMorePages = true;
            }
            else
            {
                e.HasMorePages = false;
            }
        }