Hello Every One,
I am working on a banking project where i need to print a pass Book for that i am getting all the printing records on DataGridview . Before giving print i am showing print preview . Here i want to print on pass book based on the columns in book that is i need to align the data that has to be printed on book.
I am doing this on windows form application.Here i am using printpreviewcontrol
in .net Even i am getting print preview as per my requirement but the thing is it s not getting printed. To check printer i typed some junk in word document and send to printer it is printing . Now the problem is in my code .Here is how i am writing code for printing
private void printDocument_PassBookDetails_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs ev)
{
Font ObjFont = new Font("arial", 9, FontStyle.Bold);
while (intPassBookStartLine < intPassBookEndLine)
{
ev.Graphics.DrawString(DGV_Printing.Rows[intPassBookStartLine].Cells[0].Value.ToString(), ObjFont, Brushes.Black, 10, passbookStartLine);
ev.Graphics.DrawString(DGV_Printing.Rows[intPassBookStartLine].Cells[6].Value.ToString(), ObjFont, Brushes.Black, 54, passbookStartLine);
ev.Graphics.DrawString(DGV_Printing.Rows[intPassBookStartLine].Cells[3].Value.ToString(), ObjFont, Brushes.Black, 135, passbookStartLine);
ev.Graphics.DrawString(DGV_Printing.Rows[intPassBookStartLine].Cells[7].Value.ToString(), ObjFont, Brushes.Black, 380, passbookStartLine);
ev.Graphics.DrawString(DGV_Printing.Rows[intPassBookStartLine].Cells[4].Value.ToString(), ObjFont, Brushes.Black, 450, passbookStartLine);
ev.Graphics.DrawString(DGV_Printing.Rows[intPassBookStartLine].Cells[5].Value.ToString(), ObjFont, Brushes.Black, 540, passbookStartLine);
ev.Graphics.DrawString(DGV_Printing.Rows[intPassBookStartLine].Cells[8].Value.ToString(), ObjFont, Brushes.Black, 620, passbookStartLine);
passbookStartLine += 20;
intPassBookStartLine += 1;
if (passbookStartLine > 650)
{
passbookStartLine = 80;
ev.HasMorePages = true;
return;
}
else
{
ev.HasMorePages = false;
}
}
}
Can anyone tell me actually whats wrong in code I am getting print preview as per my requirement but the thing is it is not printing.
If I hard code the data it is getting printed.
ev.Graphics.DrawString("29", ObjFont, Brushes.Black, 10, 680);
ev.Graphics.DrawString("01/01/2013", ObjFont, Brushes.Black, 60, 680);
ev.Graphics.DrawString("dgdfg cvbdf gdfgdfgd dfgdfg", ObjFont, Brushes.Black, 135, 680);
ev.Graphics.DrawString("987654", ObjFont, Brushes.Black, 380, 680);
ev.Graphics.DrawString("10000000", ObjFont, Brushes.Black, 450, 680);
ev.Graphics.DrawString("24000000", ObjFont, Brushes.Black, 540, 680);
ev.Graphics.DrawString("30000000", ObjFont, Brushes.Black, 620, 680);
Thanks in Advance,
Regards,
Arun R.V