C# Barcode Generator Library > Barcode for RDLC Report > How to Create Barcode in RDLC report? > VB.NET Barcode Library for RDLC Reports in WinForms application

How to create barcodes in VB.NET RDLC local reports in Windows Forms application?





This guide provides a structured, step-by-step workflow for barcode generation and printing in local RDLC reports (Report Definition Language Client-Side) using the BarcodeLib RDLC Report Barcode Generator library.

It supports VB.NET Windows Forms Applications and VB.NET WPF Applications built on the .NET Framework.

RDLC Local Report Barcode Generator Library

QR Code, Data Matrix, Code 128, GS1, EAN/UPC. Unicode text encoding in VB.NET RDCL Local Report Windows application.

Download Now
NuGet Ready
.NET Framework 4.x, 3.x, 2.x


Step 1. Create a New VB.NET Windows Desktop Project


  1. Open Visual Studio 2022 and select the Create a new project option.
  2. In the project template selection window: Choose Windows Forms App (.NET Framework) (VB.NET)
  3. Click Next to proceed.
  4. Set the project name as BarcodeLibRDLCBarcodeWinFormsVbnetDemo.
  5. Select your target .NET Framework version and complete project creation.


Step 2. Add Dependent Libraries and NuGet Packages


  1. In the Solution Explorer, right-click the References node of the project.
  2. Select Manage NuGet Packages from the context menu.
  3. Switch to the Browse tab, set the package source to nuget.org.
  4. Search for and install Microsoft.ReportingServices.ReportViewerControl.Winforms (latest stable version).
  5. Manually add the BarcodeLib RDLC barcode library: BarcodeLib.Barcode.RDLCReports.dll to the project references.


Step 3. Implement Barcode Printing from a DataTable in RDLC Reports


3.1 Create and Configure a Typed DataSet (Data Source)

  1. Right-click the VB.NET project in the Solution Explorer.
  2. Select Add > New Item..., then add a DataSet file named DataSet1.xsd.
  3. Open DataSet1.xsd in the designer, right-click the canvas and add a new DataTable (default name: DataTable1).
  4. Add the first column: Name it Data, set the Data Type to System.String.
  5. Add the second column: Name it Barcode, set the Data Type to System.Byte[].

Note: The Barcode column must use System.Byte[] data type. Other data types cannot render barcode images in the RDLC report.


3.2 Design the RDLC Report Template

Here we will build the report layout and bind the DataSet to the report control.

  1. Add a new RDLC Report item to the project and name it Report1.rdlc.
  2. Select Report1.rdlc in the Solution Explorer, set the Copy to Output Directory property to Copy if newer.
  3. In the Report Designer, right-click Datasets and select Add Dataset.
  4. In the Dataset Properties window:
    • Data source: Select DataSet1
    • Available datasets: Select DataTable1
  5. Insert a Table control into the report design area.
  6. Drag the Data and Barcode fields from the Report Data panel to the Table cells.
  7. Insert an Image control into the Barcode column cell
  8. Configure image control properties:
    • Image source: Select Database
    • Use this field: Select [Barcode]
    • MIME type: Select image/png
  9. Adjust the table row height and column width to fit the barcode display size.


3.3 Integrate the ReportViewer Control into the VB.NET Form

ReportViewer is a dedicated control for rendering and displaying local RDLC reports in Windows Forms.
  1. Double-click Form1.vb to open the designer, drag a ReportViewer control from the Toolbox to the form.
  2. Bind the control to the report: Select BarcodeLibRDLCBarcodeWinFormsVbnetDemo.Report1.rdlc.


3.4 VB.NET Code-Behind Implementation (Replace the Default Code)

  1. Right-click the form and select View Code to open the VB.NET code-behind file (Form1.vb).
  2. Clear the default code in Form1.vb and use the following VB.NET code to generate barcodes, populate the DataTable, and bind data to the RDLC report.
Imports System.Drawing.Imaging
Imports BarcodeLib.Barcode
Imports BarcodeLib.Barcode.RDLCReports
Imports Microsoft.Reporting.WinForms

Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        ' Prepare report data.
        Dim dt As New DataTable()
        dt.Columns.Add("Data", GetType(String))
        dt.Columns.Add("Barcode", GetType(Byte()))

        Dim site1 As String = "https://www.barcodelib.com"
        Dim site2 As String = "https://www.google.com"
        Dim site3 As String = "https://www.youtube.com"

        ' Create data for the 1st row in the table.
        Dim barcode As New LinearRDLC()
        barcode.Type = BarcodeType.CODE128
        barcode.ResizeImage = True
        barcode.ImageWidth = 400
        barcode.ImageHeight = 200
        barcode.ImageFormat = BLImageFormat.PNG

        barcode.Data = site1
        Dim imgData As Byte() = barcode.drawBarcodeAsBytes()
        dt.Rows.Add(site1, imgData)

        ' Create data for the 2nd row in the table.
        barcode.Data = site2
        imgData = barcode.drawBarcodeAsBytes()
        dt.Rows.Add(site2, imgData)

        ' Create data for the 3rd row in the table.
        barcode.Data = site3
        imgData = barcode.drawBarcodeAsBytes()
        dt.Rows.Add(site3, imgData)


        ' Configure Report
        Me.ReportViewer1.LocalReport.ReportPath = "Report1.rdlc"
        Me.ReportViewer1.LocalReport.DataSources.Clear()
        Me.ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("DataSet1", dt))


        Me.ReportViewer1.RefreshReport()
    End Sub
End Class


Step 4. Execute and Preview the RDLC Barcode Report

Now we run the VB.NET Windows Forms application and view the barcode report output.
  1. Press the shortcut key Ctrl + F5 to build and run the VB.NET Windows Forms project.
  2. The Windows application main window will load and render the RDLC report automatically.

Other .NET Barcode Generator Components