How to pass qr image from picture box to RDLC report

Total Post:17

Points:119
C#  .NET  Reporting 
C#
 1314  View(s)
Ratings:
Rate this:
I work in c# windows form in visual studio 2015 but i face problem how to pass picture box qr image to report RDLC directly without using database or sql meaning i need to show qr code image in report viewer rdlc report
  1. Post:279

    Points:1987
    Re: How to pass qr image from picture box to RDLC report

    i am going to explain print QR code in rdlc report.  below i am print two type bar code first using database table and second 

    using parameter in a single image.

    after inserting a image go to image properties set highlighted setting.

    Now write below code.

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.Data.OleDb;
    using System.Drawing.Imaging;
    using BarcodeLib.Barcode.RDLCReports;
    using BarcodeLib.Barcode;
    using Microsoft.Reporting.WinForms;
    
    namespace QRCode
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
    
                Merchant proc = new Merchant();
                var data = proc.GetProducts();
    
                LinearRDLC barcode = new LinearRDLC();
                barcode.Type = BarcodeType.CODE128;
                barcode.Data = "M I N D S T I C K S O F T W A R E";
                byte[] Bytes = barcode.drawBarcodeAsBytes();
                ReportParameter[] parameters = new ReportParameter[1];
                string sIMGBASE64 = Convert.ToBase64String(Bytes);
                parameters[0] = new ReportParameter("QRCODE", sIMGBASE64);
    
                reportViewer1.LocalReport.ReportPath = @"D:\OldSystemfiles\Aditya-Extra-Work\QRCode\QRCode\Report1.rdlc";
                ReportDataSource rds = new ReportDataSource("DataSet1", data);
                this.reportViewer1.LocalReport.DataSources.Add(rds);
                this.reportViewer1.LocalReport.SetParameters(parameters);
                this.reportViewer1.RefreshReport();
            }
        }
    
        public class SampleClass
        {
            private string m_description;
            private int m_price;
            private byte[] m_bytes;
    
            public SampleClass(string description, int price, string data)
            {
                m_description = description;
                m_price = price;
                LinearRDLC barcode = new LinearRDLC();
                barcode.Type = BarcodeType.CODE128;
                barcode.Data = data;
                m_bytes = barcode.drawBarcodeAsBytes();
            }
    
            public byte[] Bytes
            {
                get { return m_bytes; }
            }
    
            public string Description
            {
                get
                {
                    return m_description;
                }
            }
    
            public int Price
            {
                get
                {
                    return m_price;
                }
            }
        }
    
        public class Merchant
        {
            private List<SampleClass> m_products;
    
            public Merchant()
            {
                m_products = new List<SampleClass>();
                m_products.Add(new SampleClass("code128", 25, "code128"));
                m_products.Add(new SampleClass("code39", 30, "code39"));
                m_products.Add(new SampleClass("qrcode", 15, "qrcode"));
            }
    
            public List<SampleClass> GetProducts()
            {
                return m_products;
            }
        }
    }
    
    this is Result .

    I hope this will help for you.
    Thanks.



  1. Post:279

    Points:1987
    Re: How to pass qr image from picture box to RDLC report

    Step 1. Download ( BarcodeLib.Barcode.RDLCReports.dll). 

     Click here  for Download BarcodeLib.Barcode.RDLCReports.dll

    after download add reference in your windows application. 

      Modified On Apr-11-2018 06:05:33 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!