How to Generate Barcode Using C# in Windows Applications

Generate barcode system in Windows applications using C#, free demo barcode DLL with C# sample code provided
Products
Barcode in .NET WinForms
Tutorial
Demo now
License & Price
2D Barcode for .NET WinForms
1D Barcode for .NET WinForms
Barcode in .NET WinForms
Barcode Generator/Library DLL/SDK in C# .NET Windows Applications - Overview
WinForms Barcode Library & Control SDK is a robust and mature barcode system component to print and develop 40+ linear and 2D barcode images in Windows applications using programming skills or using drag-and-drop implementation. The generated barcode images in WinForms projects are highly qualified and customized to meet users` needs.
This page gives a detail guide of how to create barcode images in Windows applications using C# coding, free sample C# code is provided as guide manual and source of C# is available with purchase of royalty-free developer license. Try to use VB.NET in windows applications, please refer to generate & print barcode images in Windows applications using VB.NET. Common users may refer to three implementations to create barcode images in .NET WinForms.
Barcode Integration in Windows Applications Using C#.NET - Prerequisites and Development
Requirement
  • Terrek Barcode Generator DLL for Windows Applications
  • Microsoft .NET Framework 2.0, 3.0, 4.0 or above
  • Microsoft Visual Studio 2005 / 2008 / 2010 (any version)
  • Visual C#.NET (any version)
  • OS system above Windows 2000, such as Windows XP, Windows Vista, Windows 7, etc
Solution Project Development
  • Windows Forms Application (design-time and runtime support)
  • Console Application (runtime support)
  • Class Library (runtime support)
  • Windows Service (runtime support)
  • ASP.NET Web Services (runtime support)
Barcode Control SDK to Create Barcode Using C# Windows Applications - Installation
The method using C# code to generate barcode images dynamically in WinForms applications is easy and simple. The C# class encodes data into the appropriate barcode system symbology format and sends the created barcode string to the default printer. It is important that the correct barcode generator SDK component has installed in your PC before calling the print method of the class.
Install barcode Generator & Control SDK for C# Windows Applications
  • Download Windows Forms Barcode Creator Component SDK and save it to the local hard drive after unzipping. The DLL document should be saved or copied in the C#.NET Windows application directory where the project developed
  • Open the Visual Studio C#.NET project and add the Windows App barcode system DLL file to the project reference in Solution Explorer
Barcode Generator SDK to Create Barcode in WinForms Using C# - Barcode Image Generation
  • After barcode generator library SDK installation, drag and drop a button onto Form and double click on the button
  • Include the Terrek.barcode namespace to the solution, that is using Terrek.barcode;
  • Once the reference to the using Terrek.barcode namespace is added to the C# solution, the bar code object may be instantiated, that is BarCode barcode = new BarCode();
  • Use the C# methods associcated with the barcode system, method in the C# class take a string as an input value and encode the data to the format of the symbology. 40+ linear and 2D barcode types, functions and features are built into the Windows Forms applications with default value
  • Debug the WinForms project after barcode coding in C#
Sample C# Coding to Generate Barcode Images in WinForms Project
This following C# code is using QR Code as an example, if programmers need to generate other barcode system types, change relevant barcode symbols and barcode data accordingly. Special barcode settings may be appended according to the functionality of the barcode generator for WinForms.
using Terrek.Barcode;
BarcodeControl qrcode = new BarcodeControl();
qrcode. Symbol = BarcodeSymbol.QRCode;
qrcode.BarcodeData = "http://www.terrek.com/products/aspnet_barcode/aspnet_qrcode.shtml";
qrcode.QRCodeDataMode=QRCodeDataMode.Auto;
qrcode.QRCodeECL=QRCodeECL.H;
//qrcode image setting
qrcode.DotsPerInch = 96;
qrcode.BarcodeFormat = System.Drawing.Imaging.ImageFormat.Png;
qrcode.drawBarcode("C:\\qrcode.png");
//qrcode size setting
qrcode.ImageResize = true;
qrcode.MeasuringUnit = MeasuringUnit.PIXEL;
qrcode.BarWidth = 2;
qrcode.QRVersion=QRCodeVersion.V10;
qrcode.ImageWidth = 0;
qrcode.ImageHeight = 0;
qrcode. MarginL = 10;
qrcode. MarginR = 10;
qrcode. MarginT = 10;
qrcode. MarginB = 10;
//qrcode barcode placement setting
qrcode.Rotation = Rotation.Degree0;
qrcode.BarAlign = BarAlign.Center;
//qrcode color setting
qrcode. ImageColor = Color.White;
qrcode. BarColor = Color.Black;