C # How to dynamically display multiple bar code labels in RDLC reports,
C # For Beginners, as the company's customers recently asked the original shipping labels to be standardized, the opportunity for hands-on training came. As a result, they started to work on this program, and they started to perform some operations to add, delete, modify, and query operations smoothly, however, it is difficult to display the bar code in the RDLC report to the report. Because the beginner has not been in touch with the report, no information can be found on the Internet, the byte [] array and image Conversion Method in an article can be seen by chance to display images in an RDLC report. With the idea, I started to think about how to do it and paste the code. I am very pleased to write the code for the first time.
Customer requirement tag Template
My idea is: instead of using a database to store the byte [] data of an image, I first save all the required barcode data to a database table, then, when the bar code needs to be displayed in the RDLC report, obtain the bar code data in the table, and create a dataset (used to store all the data needed in the report ), use barcodelib. dll generates a bar code object and returns an image object. Then, use the following method to convert the returned image object to a byte [] array and store it in the new dataset.
Other code will not be pasted, because a lot of things are not encapsulated and code-up is too long.
1 // convert the image object to the byte array 2 public static byte [] ImageToBytes (Image img) 3 {4 ImageConverter imgconv = new ImageConverter (); 5 byte [] B = (byte []) imgconv. convertize (img, typeof (byte []); 6 return B; 7}
Create a template in RDLC, add the data source to the dataset you just created, insert the image object, select the database for the image source, and use this field to enter System. Convert. ToBase64String (Fields! Store the byte [] column name of the image object. Value)
RDLC Report Template!
View the actual results