I am printing barcode using datagridview value. Datagridview having 2 Columns
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();
- }