Java Barcode Generator, .NET Barcode Generator for C#, ASP.NET, VB.NET
HOME BARCODE FOR .NET RDLC PURCHASE

How to Create Barcodes for RDLC Reports in .NET Windows Forms



Developer Guide
Quick Navigate





1. 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

2. Create Barcode Image in RDLC Reports for .NET Windows Forms
  • Create a new Windows Application Project.
    1. Create a new "Windows Applicaton" project, named "BarcodeforRDLCReports".


  • Add a new DataSet to the project.
    1. Add a new item (DataSet), named "AdventureWorks.xsd" to the project. view image
    2. 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
    3. Select "Use SQL statements" as the way TableAdapter access the database. view image
    4. Use "SELECT ProductID, Name FROM Production.vProductAndDescription WHERE (CultureID = N'en')" as SQL statements.
      Click "Finish" button. view image
    5. Right click "vProductAndDescription" on the DataSet, and insert a new column in the DataTable, named "Barcode". view image
    6. Change "Barcode" data type to "System.Byte[]" (Please input manually if it is necessary). Save the "AdventureWorks.xsd". view image


  • Add a new Report to the window form.
    1. Add a new report (Report), named "RDLCReports.rdlc" to the project. view image
    2. In Report Items from Toolbox, insert a "Table" to the report. view image
    3. In DataSet "AdventureWorks.xsd", add three columns to the report table details section. view image
    4. Drag an "Image" item to the last column "Barcode". view image
    5. Set image properties "MIMEType" to "image/jpeg", "Source" to "Database", and "Value" to "=Fields!Barcode.Value".
      Save the report. view image


  • Add a Report Viewer to the window form.
    1. Resize "Form1", and add "ReportViewer" to the form, with the default setting unchanged. view image
    2. In "ReportViewer Tasks" window, choose your created report "BarcodeforRDLCReports.RDLCReports.rdlc". view image
    3. Bind data collection: In Visual Studio menu bar, choose "Data Sources..." from "Report" tab. view image
    4. Select "AdventureWorks.xsd_vProductAndDescription" as data sources. Click "Add to Report", then "OK" button. view image
    5. Again, in "ReportViewer Tasks" window, choose "Rebind Data Sources". view image
    6. Add "BarcodeLib.Barcode.RDLCReports.dll" to the project reference.
    7. Add the following code to the "Form1.cs" file.
      using System.Data.OleDb;
      using System.Drawing.Imaging;
      using BarcodeLib.Barcode.RDLCReports;
      using BarcodeLib.Barcode;
      
    8. Add the following code to the "Form1.cs" file.
      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();
      }


  • Run the project.


 

3. Property Settings for Each Barcode Types











   Copyright BarcodeLib.com. All rights reserved.