Why Join
Become a member
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
C# Corner Home
Technologies
Monthly Leaders
ASK A QUESTION
Forumguidelines
Ashfaque Baig
1.9k
66
986
Barcode copies print based on column value
Sep 11 2020 11:52 AM
I am printing barcode using datagridview value. Datagridview having 2 Columns
PRODUCTID
COPY
I am able to print single barcode from each row value , but I want more than one barcode of each row based on 2nd column value "COPY". Can any one help me to make changes in my code to meet the resul as per my requirement.
private
void
printDocument1_PrintPage(
object
sender, PrintPageEventArgs e) {
int
ypos = 20;
for
(
int
i = noofitemsprinted; i < dataGridBARCODE.RowCount; i++) {
if
(!dataGridBARCODE.Rows[i].IsNewRow) {
NoofitemsPerpage = NoofitemsPerpage + 1;
if
(NoofitemsPerpage <= 10) {
noofitemsprinted++;
if
(noofitemsprinted <= dataGridBARCODE.RowCount) {
e.Graphics.DrawString(
"*"
+ dataGridBARCODE.Rows[i].Cells[
"PRODUCTID"
].Value.ToString() +
"*"
,
new
Font(
"Code39AzaleaNarrow3"
, 20, FontStyle.Regular), Brushes.Black,
new
Point(25, ypos + 20));
ypos = ypos + 100;
}
else
{
e.HasMorePages =
false
;
}
}
else
{
NoofitemsPerpage = 0;
e.HasMorePages =
true
;
return
;
}
}
}
NoofitemsPerpage = 0;
noofitemsprinted = 0;
int
height = dataGridBARCODE.Height;
dataGridBARCODE.Height = dataGridBARCODE.RowCount * dataGridBARCODE.RowTemplate.Height;
bitmap =
new
Bitmap(
this
.dataGridBARCODE.Width,
this
.dataGridBARCODE.Height);
dataGridBARCODE.DrawToBitmap(bitmap,
new
Rectangle(0, 0,
this
.dataGridBARCODE.Width,
this
.dataGridBARCODE.Height));
dataGridBARCODE.Height = height;
}
private
void
button1_Click(
object
sender, EventArgs e) {
printPreviewDialog1.Document = printDocument1;
printPreviewDialog1.ShowDialog();
}
Reply
Answers (
0
)
How to make server IP address static
How can insert a datagridview combobox values in to database table in