KA.Barcode for .NET WinForms
How to Create & Resize Code 128 in .NET WinForms
High-quality control to generate, print Code 128 barcode images in .NET WinForms projects
  • Compatible with .NET Framework and Microsoft Visual Studio .NET
  • Simple 1D Code 128A, Code 128B, Code 128C image generation in .NET Windows projects
  • Provide detailed C# barcode tutorial, .NET WinForms barcode sample & .NET barcode sample guides for users
  • Easily draw multiple Code 128 barcodes with flexible bar width and height in Windows Forms
  • Drawing, creating multiple Code 128 with quiet zones/ margins on the left & right sides
  • Draw .NET Interleaved 2 of 5, Word UPC-A, .NET WinForms Intelligent Mail, EAN 128 Word & other .NET EAN 128 in .NET IDEs
  • Automatic check digit calculation for Code 128 bar code according to algorithm in ISO specification
  • Output valid 1D Code 128 compatible with ISO / IEC 15417 for all scanners
  • Support thermal printer to printout outstanding Code 128 pictures
KeepAutomation barcode generator component software SDK library support printing Code 128 and other linear, bidimensional barcode symbologies in .NET Windows applications, as well as Crystal Reports, C#, Visual Basic .NET programming.
This page will guide you for image sizing. Here are two more tutorials for data encoding and image setting:
Code 128 Size Setting with C#, VB.NET Class in .NET WinForms

Install Code 128 Barcode Creator Component Library into .NET WinForms

  1. 1.
  2. 2.
    Add Reference: Add "KeepAutomation.Barcode.Windows.dll"to your .NET WinForms project reference
  3. 3.
    Add to toolbox: To add Code 128 BarcodeControl to your Visual Studio .NET toolbox
Copy the C#, VB.NET barcode program below to print, produce a Code 128 in .NET WinForms applications:
using KeepAutomation.Barcode.Bean;
BarCode barcode= new BarCode();
barcode.Symbology= KeepAutomation.Barcode.Symbology.Code128Auto;
barcode.CodeToEncode = "Code128";
Dim barcode As KeepAutomation.Barcode.Bean.BarCode = New KeepAutomation.Barcode.Bean.BarCode

barcode.Symbology= KeepAutomation.Barcode.Symbology.Code128Auto
barcode.CodeToEncode = "Code128"

Creating Code 128 with Pixel as Unit of Measure

With KA.Barcode Generator for .NET WinForms, users are allowed to print Code 128 with three units of measure, i.e. Pixel, Cm, and Inch. Default value is Pixel. You can copy the example codings below to adjust:
barcode.BarcodeUnit = BarcodeUnit.Pixel;
barcode.BarcodeUnit = BarcodeUnit.Pixel

Generating Code 128 with Defined Bar Width & Height (X & Y)

This Code 128 barcode control provides user-friendly interface to developers to easily adjust Code 128 bar width through "X" dimension. "Y" dimension is the parameter for Code 128 bar height. You can adjust the two dimensions through the following codings:
barcode.X = 2;
barcode.Y = 60;
barcode.X = 2
barcode.Y = 60
If you want to draw a Code 128 with a fixed size to fit into a specific space, just adjust the "BarCodeWidth" and "BarCodeHeight" dimensions. Here is a sample code for you:
barcode.BarCodeWidth = 200;
barcode.BarCodeHeight = 75;
barcode.BarCodeWidth = 200
barcode.BarCodeHeight = 75

Painting Code 128 with Quiet Zones/ Margins on Four Sides

According to the ISO/ IEC Code 128 specification, a minimum of 10X margin is required on the left & right side of a Code 128 image, which is already automatically added by KA.Barcode Generator for .NET WinForms. If you want to add more margins on all four sides, just copy the sample below:
barcode.TopMargin = 6;
barcode.BottomMargin = 6;
barcode.LeftMargin = 6;
barcode.RightMargin = 6;
barcode.TopMargin = 6
barcode.BottomMargin = 6
barcode.LeftMargin = 6
barcode.RightMargin = 6
Code 128 Size Setting with Drag & Drop BarcodeControl in .NET WinForms
  1. 1.
    Add .NET WinForms Creator BarCodeControl into Visual Studio .NET Toolbox
  2. 2.
    Drag and drop the BarCodeControl into the Forms to generate a Codabar at default
  3. 3.
    Right click the barcode to select "Properties" and choose"Code128" in the "Symbology" and input data to encode
  4. 4.
    Set "X" to 2, "Y" to "60", "BarCodeHeight" to "75", and "BarCodeWidth" to 180 pixels
  5. 5.
    Click the generated barcode and the customized Code 128 is updated