C # How to dynamically display multiple bar code labels in RDLC reports,

Source: Internet
Author: User

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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.