Our Customers
Contact Us Email: support@barcodelib.com
Home > .NET RDLC Reports Barcode > .NET, C#, VB.NET Barcode DLL for RDLC Reports for .NET WinForms
Download Barcode for RDLC Reports Trial

How to Generate Barcodes with RDLC Reports for .NET in .NET Windows Applications

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 .NET Windows Forms
  1. Create a new Windows Application Project.
    • Create a new "Windows Applicaton" project, named "BarcodeforRDLCReports".
  2. Add a new DataSet to the project.
    • Add a new item (DataSet), named "AdventureWorks.xsd" to the project. view image
    • Drag the "TableAdapter" to your created DataSet. Create a new connection or use existing connection to SQL Server AdventureWorks Sample Database. view image. Then, click "Next".view image
    • Select "Use SQL statements" as the way TableAdapter access the database. view image
    • Use "SELECT ProductID, Name FROM Production.vProductAndDescription WHERE (CultureID = N'en')" as SQL statements.
      Click "Finish" button. view image
    • Right click "vProductAndDescription" on the DataSet, and insert a new column in the DataTable, named "Barcode". view image
    • Change "Barcode" data type to "System.Byte[]" (Please input manually if it is necessary). Save the "AdventureWorks.xsd". view image
  3. Add a new Report to the window form.
    • Add a new report (Report), named "RDLCReports.rdlc" to the project. view image
    • In Report Items from Toolbox, insert a "Table" to the report. view image
    • In DataSet "AdventureWorks.xsd", add three columns to the report table details section. view image
    • Drag an "Image" item to the last column "Barcode". view image
    • Set image properties "MIMEType" to "image/jpeg", "Source" to "Database", and "Value" to "=Fields!Barcode.Value".
      Save the report. view image
  4. Add a Report Viewer to the window form.
    • Resize "Form1", and add "ReportViewer" to the form, with the default setting unchanged. view image
    • In "ReportViewer Tasks" window, choose your created report "BarcodeforRDLCReports.RDLCReports.rdlc". view image
    • Bind data collection: In Visual Studio menu bar, choose "Data Sources..." from "Report" tab. view image
    • Select "AdventureWorks.xsd_vProductAndDescription" as data sources. Click "Add to Report", then "OK" button. view image
    • Again, in "ReportViewer Tasks" window, choose "Rebind Data Sources". view image
    • 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;

// 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();
}
4. Run the project.

Related .NET Barcode Generator SDKs