Barcode .NET C# Tutorial

How to use our Barcode .NET control from Microsoft C#.


1. Install our Barcode .NET Control and start Microsoft Visual Studio. Create a new project after that.

Start Microsoft Visual Studio and create a new project.

2. Register Barcode .NET Control in your application. Open Toolbox for that.

Register Barcode .NET Control in your application.

3. Right-click to open the context menu and select Customize Toolbox.

Customize Toolbox

4. Switch to the .NET Framework Components tab and click the Browse button. Then select the file Barcodes.Barcode.dll.

select the file Barcodes.Barcode.dll

5. Now the Barcode .NET Control is present on the Windows Forms tab. You can put it on the form.

Put Barcode .NET Control to form

6. Adjust the properties of the Barcode .NET Control.

Adjust the barcode .NET properties

7. Place the code for using the control.

The following code saves the barcode image to an image file. The barcode will have x-dimension equal to 2 pixels.
double wPix;
barcodeControl1.GetBarcodeWidth( 2, 1, 1, Barcodes.Barcode.Dimensions.dmPixels,
    Barcodes.Barcode.Dimensions.dmPixels, out wPix );
barcodeControl1.SaveToImageFile( wPix, 100, "c:\\Barcode.bmp", 96,
    Barcodes.Barcode.Dimensions.dmPixels );
Copies the barcode image to the clipboard.
barcodeControl1.CopyToClipboard( 250, 100 );
The barcode can be displayed in any Graphics object or Device Context (HDC).
Graphics gr = this.CreateGraphics();
barcodeControl1.DrawBarcodeToSize( 350, 10, 250, 100,
    Barcodes.Barcode.Dimensions.dmPixels, gr );
This code allows you to print the barcode on the printer.
private void button4_Click(object sender, System.EventArgs e)
    PrintDocument pd = new PrintDocument();
    pd.PrintPage += new PrintPageEventHandler( this.OnPrintBarcodePage );
				catch( Exception ex ) 
    MessageBox.Show( ex.Message );
// The OnPrintBarcodePage event is raised for each page to be printed.
private void OnPrintBarcodePage(object sender, PrintPageEventArgs ev) 
				double wMM;
  barcodeControl1.GetBarcodeWidth( 0.5, (int)ev.Graphics.DpiX, (int)ev.Graphics.DpiY,
    Barcodes.Barcode.Dimensions.dmMM, Barcodes.Barcode.Dimensions.dmMM,
				out wMM );
				// print a barcode
  barcodeControl1.DrawBarcodeToSize(10, 10, 25, wMM,
    Barcodes.Barcode.Dimensions.dmMM, ev.Graphics );

The installation package contains the entire example of how to use our Barcode .NET Control. The example is written in MS C#.