Ashfaque Baig

Ashfaque Baig

  • NA
  • 66
  • 2.9k

Barcode copies print based on column value

Sep 11 2020 11:52 AM
I am printing barcode using datagridview value. Datagridview having 2 Columns
  1. PRODUCTID
  2. 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.
  1. private void printDocument1_PrintPage(object sender, PrintPageEventArgs e) {  
  2.   int ypos = 20;  
  3.   for (int i = noofitemsprinted; i < dataGridBARCODE.RowCount; i++) {  
  4.     if (!dataGridBARCODE.Rows[i].IsNewRow) {  
  5.       NoofitemsPerpage = NoofitemsPerpage + 1;  
  6.       if (NoofitemsPerpage <= 10) {  
  7.         noofitemsprinted++;  
  8.         if (noofitemsprinted <= dataGridBARCODE.RowCount) {  
  9.           e.Graphics.DrawString("*" + dataGridBARCODE.Rows[i].Cells["PRODUCTID"].Value.ToString() + "*"new Font("Code39AzaleaNarrow3", 20, FontStyle.Regular), Brushes.Black, new Point(25, ypos + 20));  
  10.           ypos = ypos + 100;  
  11.         } else {  
  12.           e.HasMorePages = false;  
  13.         }  
  14.       } else {  
  15.         NoofitemsPerpage = 0;  
  16.         e.HasMorePages = true;  
  17.         return;  
  18.       }  
  19.     }  
  20.   }  
  21.   NoofitemsPerpage = 0;  
  22.   noofitemsprinted = 0;  
  23.   int height = dataGridBARCODE.Height;  
  24.   dataGridBARCODE.Height = dataGridBARCODE.RowCount * dataGridBARCODE.RowTemplate.Height;  
  25.   bitmap = new Bitmap(this.dataGridBARCODE.Width, this.dataGridBARCODE.Height);  
  26.   dataGridBARCODE.DrawToBitmap(bitmap, new Rectangle(0, 0, this.dataGridBARCODE.Width, this.dataGridBARCODE.Height));  
  27.   dataGridBARCODE.Height = height;  
  28. }  
  29. private void button1_Click(object sender, EventArgs e) {  
  30.   printPreviewDialog1.Document = printDocument1;  
  31.   printPreviewDialog1.ShowDialog();  
  32. }