Our Customers
Contact Us Email: support@barcodelib.com
Home > .NET RDLC Reports Barcode > Barcode Generation Guide > C# Barcode Library for RDLC Reports
Download Barcode for RDLC Reports Trial

How to Create Barcodes in .NET RDLC Local Reports using Visual C#

Prerequisites
  • BarcodeLib.Barcode.RDLCReports.dll
  • Microsoft .NET Framework 2.0 (or later)
  • SQL Server 2005 (any edition) with AdventureWorks Database installed
  • Microsoft Visual Studio 2005 or later version
Create Barcode Image in RDLC Reports for ASP.NET using C#
BarcodeLib RDLC Report Barcode Generator supports barcode image printing in RDL Reports for ASP.NET web applications using Visual C#. Here is a simple developer guide for you. To know more, please view how to print barcodes in RDLC Report for ASP.NET.
  1. Create a new ASP.NET Web Application Project.
  2. Add a new Class to the project and Add Reference.
    • Add a new item (Class), named "SampleClass.cs" to the project.
    • Add "BarcodeLib.Barcode.RDLCReports.dll" to the project reference.
    • Add the following sample code to your created class "APP_Code/SampleClass.cs".
    • In Visual Studio menu bar, choose "Build Web Site" from "Build" tab.
     using System.Collections.Generic;
using BarcodeLib.Barcode.RDLCReports;
using BarcodeLib.Barcode;


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;

barcode.LeftMargin = 0;
barcode.RightMargin = 0;
barcode.TopMargin = 0;
barcode.BottomMargin = 0;

// more barcode settings here

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;
}
}
3. Add a new Report to the web form.
4. Add a Report Viewer to the web form.
5. Resize the "ReportViewer", and run the project.
Create Barcode Image in RDLC Reports for .NET Windows Forms with C#
BarcodeLib RDLC Report Barcode Generator also makes it easy to print barcodes in RDL Reports in .NET Windows applications using Visual C#. Below is a simplified tutorial, for more details, please view how to print barcodes in RDLC Report for .NET windows forms.
  1. Create a new Windows Application Project.
  2. Add a new DataSet to the project.
  3. Add a new Report to the window form.
  4. Add a Report Viewer to the window form.
    • Resize "Form1", and add "ReportViewer" to the form, with the default setting unchanged.
    • In "ReportViewer Tasks" window, choose your created report "BarcodeforRDLCReports.RDLCReports.rdlc".
    • Bind data collection: In Visual Studio menu bar, choose "Data Sources..." from "Report" tab.
    • Select "AdventureWorks.xsd_vProductAndDescription" as data sources. Click "Add to Report", then "OK" button.
    • Again, in "ReportViewer Tasks" window, choose "Rebind Data Sources".
    • Add "BarcodeLib.Barcode.RDLCReports.dll" to the project reference.
    • Add the following code to the "Form1.cs" file.
     using System.Data.OleDb;
using System.Drawing.Imaging;
using BarcodeLib.Barcode.RDLCReports;
using BarcodeLib.Barcode;


private void Form1_Load(object sender, EventArgs e)
{
// load data to the data table
this.vProductAndDescriptionTableAdapter.Fill(this.AdventureWorks.vProductAndDescription);

// create a linear barcode object
LinearRDLC barcode = new LinearRDLC();

// set barcode type to Code 128
barcode.Type = BarcodeType.CODE128;

// more barcode settings here

// draw barcodes for each data row
foreach (AdventureWorks.vProductAndDescriptionRow row in this.AdventureWorks.vProductAndDescription.Rows)
{
// set barcode encoding data value
barcode.Data = row.ProductID.ToString();

// set drawing barcode image format
barcode.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;

row.Barcode = barcode.drawBarcodeAsBytes();
}

this.reportViewer1.RefreshReport();
}
5. Run the project.

Other .NET Barcode Generator Components