Barcode for RDLC > Generate Barcode in .NET WinForms

How to Generate Barcodes in RDLC in WinForms

Encoding, Adjusting &Printing Barcodes in RDLC Reports in .NET WinForms

KA.Barcode for RDLC Reports Description
KeepAutomation Barcode Generator for RDLC Reports is an easy-to-integrate library that allows developers to print high-quality barcode images in RDLC Reports in .NET WinForms. This page introduces the working environment of Barcode for RDLC .NET and walks you through the setup and generation steps of this SDK tool in Report Definition Language Client-Side (RDLC) Reports in .NET Windows Forms applications. Free sample codes in VB.NET and C#.NET are presented in the end of this page.
Compatibility & Requirements
  • Development Environments: Visual Studio 2005/2008 /2010, .NET Version greater than 2.0, Visual C#.NET & Visual Basic .NET
  • Compatible Operating Systems: Windows 2000, XP, Vista, and Windows 7
  • System Requirements: 500 MHZ processor, 128 MB RAM, 5 MB available hard drive space
Test Environment
  • Microsoft Windows XP
  • Microsoft Visual Studio 2005
  • Visual C#.NET
How to Generate Barcodes in RDLC in WinForms

Download Demo Package
Create A RDLC Report in Windows Forms
  1. Open your Visual Studio, then create a Windows Forms application.
  2. Create a "DataSet" with the name "AdventureWorks.xsd".
  3. Go to the Toolbox to select "Pointer", then drag & drop "Table Adapter" to the new DataSet.
  4. Define the connection to SQL Server AdventureWorks Sample Database.
  5. Use the following string as SQL Statement: "SELECT ProductID, Name FROM Production.vProductAndDescription WHERE (CultureID = N'en') ".
  6. Right click "vProductAndDescription" on the dataset to create a column named "Barcode", and change the data type to "System.Byte[]" in "Properties" window.
  7. Create a new "Report", insert a table to the report, and add three columns in the dataset to the report table details section.
  8. Drag and drop "Image" item to the last column, named as "Barcode".
  9. Switch to the "Properties" window, and set the following properties: set "Source" to Database; set "MIMEType" to "image/jpeg"; set "Value" to "=Fields!Barcode.Value".
  10. Select "Form1.cs[Design]", drag "ReportViewer" to Form1, and bind the data collection.
  11. Add "KeepAutomation.Barcode.RDLC.dll" to project reference.
  12. Copy the sample code into the method Form1_Load.
  13. Use "KeepAutomation.Barcode.RDLC" namespace and run your project.
C# Sample code
     private void Form1_Load(object sender, EventArgs e)
{
// load data to the data table this.vProductAndDescriptionTableAdapter.Fill
this.vProductAndDescriptionTableAdapter.Fill(this.AdventureWorks.vProductAndDescription);
// create a linear barcode object
BarCode barcode = new BarCode();
// set barcode type
barcode.Symbology = KeepAutomation.Barcode.Symbology.DataMatrix;
barcode.X = 4;
barcode.Y = 4;
// draw barcodes for each data row
foreach (AdventureWorks.vProductAndDescriptionRow
row in this.AdventureWorks.vProductAndDescription.Rows)
{// set barcode encoding data value
barcode.CodeToEncode = row.ProductID.ToString();
// set drawing barcode image format
barcode.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;
row.Barcode = barcode.generateBarcodeToByteArray();
}
this.reportViewer1.RefreshReport();
}

VB Sample code
     Private Sub Form1_Load(sender As Object, e As EventArgs)
' load data to the data table this.vProductAndDescriptionTableAdapter.Fill
Me.vProductAndDescriptionTableAdapter.Fill(Me.AdventureWorks.vProductAndDescription)
' create a linear barcode object
Dim barcode As New BarCode()
' set barcode type
barcode.Symbology = KeepAutomation.Barcode.Symbology.DataMatrix
barcode.X = 4
barcode.Y = 4
' draw barcodes for each data row
For Each row As AdventureWorks.vProductAndDescriptionRow In Me.AdventureWorks.vProductAndDescription.Rows
' set barcode encoding data value
barcode.CodeToEncode = row.ProductID.ToString()
' set drawing barcode image format
barcode.ImageFormat = System.Drawing.Imaging.ImageFormat.Png

row.Barcode = barcode.generateBarcodeToByteArray()
Next
Me.reportViewer1.RefreshReport()
End Sub

CompatibilityTest EnvironmentWindows RDLC ReportsUsing C#Using VB.NETUsing ASP.NETUsing .NET WinformsData Matrix for RDLCPDF417 for RDLCQR Code for RDLCmoreCodabar for RDLCCode 39 for RDLCCode 128 for RDLCEAN-8 for RDLCEAN-13 for RDLCEAN 128 for RDLCIntelligent Mail for RDLCInterleaved 2 of 5 for RDLCISBN for RDLCITF-14 for RDLCRM4SCC for RDLCUPC-A for RDLCUPC-E for RDLCmore
KeepAutomation provides complete barcode automation solutions for add barcode display 2-dimensional, barcode generation capacity api, and barcode mobile applications. We recommend the customers use high quality ASP.NET html5 document viewer, c# pdf sdk, C# merge PDF files, Split PDF in C#, C# View, edit PDF online , C# Convert PDF to Tiff, C# Convert PDF to text, txt, .net imaging sdk, C# PDF metadata edit from RasterEdge.com.