How to Generate Barcodes in RDLC in WinFormsEncoding, 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
- 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
- Open your Visual Studio, then create a Windows Forms application.
- Create a "DataSet" with the name "AdventureWorks.xsd".
- Go to the Toolbox to select "Pointer", then drag & drop "Table Adapter" to the new DataSet.
- Define the connection to SQL Server AdventureWorks Sample Database.
- Use the following string as SQL Statement: "SELECT ProductID, Name FROM Production.vProductAndDescription WHERE (CultureID = N'en') ".
- Right click "vProductAndDescription" on the dataset to create a column named "Barcode", and change the data type to "System.Byte[]" in "Properties" window.
- Create a new "Report", insert a table to the report, and add three columns in the dataset to the report table details section.
- Drag and drop "Image" item to the last column, named as "Barcode".
- 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".
- Select "Form1.cs[Design]", drag "ReportViewer" to Form1, and bind the data collection.
- Add "KeepAutomation.Barcode.RDLC.dll" to project reference.
- Copy the sample code into the method Form1_Load.
- 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 Reports How To Start Using 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
|