HOW TO USE BARCODE IN C# WINDOWS FORM

USE BARCODE WITH C# WINDOWS FORM
Barcode or Qrcode is the technique to encode the data ex. Text,url or etc into encoded image format to provide confidential access to the data. In shopping malls you may see they are scaning those barcode prited on products and then get the description of the perticuler product from their server database. For those kind of activity we have to generate those barcode.

Step 1: Download QRCODE GENERATOR LIBRARY from onbarcode.com.

Step 2: Open Visual Studio - Create New Project - Windows Form.

Step 3: Add reference to OnBarcode.Barcode.Winforms.dll.

Step 4: Design form with some input fields for accepting data to encode and the targeted location to save barcode generated image.

Step 5: To generate Barcode as well as Qrcode images write two differen methods as follows.
        private void GenerateBacode(string _data, string _filename)
        {
            Linear barcode = new Linear();
            barcode.Type = BarcodeType.CODE11;
            barcode.Data = _data;
            barcode.drawBarcode(_filename);
        }        private void GenerateQrcode(string _data, string _filename)
        {
            QRCode qrcode = new QRCode();
            qrcode.Data = _data;
            qrcode.DataMode = QRCodeDataMode.Byte;
            qrcode.UOM = UnitOfMeasure.PIXEL;
            qrcode.X = 3;
            qrcode.LeftMargin = 0;
            qrcode.RightMargin = 0;
            qrcode.TopMargin = 0;
            qrcode.BottomMargin = 0;
            qrcode.Resolution = 72;
            qrcode.Rotate = Rotate.Rotate0;
            qrcode.ImageFormat = ImageFormat.Gif;
            qrcode.drawBarcode(_filename);
        }


Barcode:
Barcode in C#

Qrcode:

qrcode in C#


No comments:

Post a Comment