TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Bharathi Raja
NA
1.1k
54k
How to Print Multi Pages in C# windows forms
Jun 11 2018 5:40 AM
hai
First 50 values print one page other 50 values not Print
Next page print in other values new page print ..
..This is my code
.
private
void
A5_PrintPage(
object
sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Font cash =
new
Font(
"Arial"
, 10, FontStyle.Bold);
Font bill_no =
new
Font(
"Arial"
, 8, FontStyle.Bold);
Font shf1 =
new
Font(
"Arial"
, 8, FontStyle.Regular);
Font shf2 =
new
Font(
"Arial"
, 8, FontStyle.Italic);
Font shf3 =
new
Font(
"Arial"
, 8, FontStyle.Bold);
Font items =
new
Font(
"Arial"
, 8, FontStyle.Regular);
Font item_head =
new
Font(
"Arial"
, 10, FontStyle.Regular);
Font line =
new
Font(
"Arial"
, 8, FontStyle.Regular);
Font tax =
new
Font(
"Arial"
, 6, FontStyle.Regular);
Font title =
new
Font(
"Arial"
, 18, FontStyle.Bold);
Font address =
new
Font(
"Arial"
, 10, FontStyle.Bold);
Font item_eng1 =
new
Font(
"Arial"
, 8, FontStyle.Regular);
Font item_tamil1 =
new
Font(
"Arial"
, 8, FontStyle.Regular);
int
i = 50;
e.Graphics.DrawString(
"S.No"
, item_head, Brushes.Black, 20, i);
e.Graphics.DrawString(
"NAME"
, item_head, Brushes.Black, 100, i);
e.Graphics.DrawString(
"MOBILE"
, item_head, Brushes.Black, 200, i);
e.Graphics.DrawString(
"EMAIL"
, item_head, Brushes.Black, 350, i);
e.Graphics.DrawString(
"COMPANY"
, item_head, Brushes.Black, 450, i);
e.Graphics.DrawString(
"BALANCE"
, item_head, Brushes.Black, 550, i);
e.Graphics.DrawString(
"ADDRESS"
, item_head, Brushes.Black, 650, i);
//e.Graphics.DrawString("QTY", item_head, Brushes.Black, 650, i);
//e.Graphics.DrawString("QTY", item_head, Brushes.Black, 750, i);
//e.Graphics.DrawString("TAX", item_head, Brushes.Black, 820, i);
i = i + 15;
e.Graphics.DrawString(
"--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------"
, SystemFonts.DefaultFont, Brushes.Black, 20, i);
i = i + 15;
double
qty = 0.00, tax1 = 0, rate = 0.00, tot_qty = 0.00, price = 0;
string
bal =
""
, name =
""
, tax2,ADD,mob,mail,com;
int
s_no;
Rectangle rect_right =
new
Rectangle();
StringFormat str_right =
new
StringFormat();
str_right.LineAlignment = StringAlignment.Near;
int
line_no = 0;
for
(
int
ct = line_no; ct < list_customer_grid.Rows.Count; ct++)
{
s_no = ct + 1;
name = list_customer_grid.Rows[ct].Cells[2].Value.ToString();
mob = list_customer_grid.Rows[ct].Cells[3].Value.ToString();
mail = list_customer_grid.Rows[ct].Cells[4].Value.ToString() ;
com = list_customer_grid.Rows[ct].Cells[5].Value.ToString();
bal = list_customer_grid.Rows[ct].Cells[6].Value.ToString();
ADD = list_customer_grid.Rows[ct].Cells[8].Value.ToString();
str_right.Alignment = StringAlignment.Near;
rect_right =
new
Rectangle(20, i, 135, 20);
e.Graphics.DrawString(
string
.Format(
"{0}"
, s_no), items, Brushes.Black, rect_right, str_right);
str_right.Alignment = StringAlignment.Near;
rect_right =
new
Rectangle(100, i, 135, 20);
e.Graphics.DrawString(
string
.Format(
"{0}"
, name), items, Brushes.Black, rect_right, str_right);
str_right.Alignment = StringAlignment.Near;
rect_right =
new
Rectangle(200, i, 135, 20);
e.Graphics.DrawString(
string
.Format(
"{0}"
, mob), items, Brushes.Black, rect_right, str_right);
// i = i + 5;
str_right.Alignment = StringAlignment.Near;
rect_right =
new
Rectangle(300, i, 135, 40);
e.Graphics.DrawString(
string
.Format(
"{0}"
, mail), items, Brushes.Black, rect_right, str_right);
i = i + 5;
str_right.Alignment = StringAlignment.Near;
rect_right =
new
Rectangle(450, i, 135,40);
e.Graphics.DrawString(
string
.Format(
"{0}"
, com), items, Brushes.Black, rect_right, str_right);
i = i + 5;
str_right.Alignment = StringAlignment.Near;
rect_right =
new
Rectangle(580, i, 135, 20);
e.Graphics.DrawString(
string
.Format(
"{0}"
, bal), items, Brushes.Black, rect_right, str_right);
str_right.Alignment = StringAlignment.Near;
rect_right =
new
Rectangle(650, i, 135, 20);
e.Graphics.DrawString(
string
.Format(
"{0}"
, ADD), items, Brushes.Black, rect_right, str_right);
// e.HasMorePages = true;
i = i + 10;
}
}
private
void
button3_Click(
object
sender, EventArgs e)
{
if
(list_customer_grid.Rows.Count != 0)
{
A5.PrintController =
new
System.Drawing.Printing.StandardPrintController();
A5.PrinterSettings.PrinterName = Global_Class.printer_name;
A5.DefaultPageSettings.PaperSize.RawKind = 512;
A5.Print();
//PrintDocument pd = new PrintDocument();
//pd.PrintPage += new PrintPageEventHandler(A5_PrintPage);
//pd.Print();
}
else
{
MessageBox.Show(
"Complete all detailes"
,
"Warning"
, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
Reply
Answers (
3
)
How to Multiple Page Print
Updating label with data from thread