Create Barcodes with C# Windows Forms

Step 1. Add a Reference to BarCodeWizFontsNet.dll

  • Click on Project > Add Reference...
Add a reference to the project
  • Click Browse...
Click on Browse
  • Locate BarCodeWizFontsNet.dll and click Add. The default location is:
    C:\Program Files (x86)\BarCodeWiz Code 128 Fonts\Addins\DotNet\NET40 (use with .NET 4.0 or newer)
    C:\Program Files (x86)\BarCodeWiz Code 128 Fonts\Addins\DotNet\NET20 (use with .NET 2.0 or 3.5)
Locate BarCodeWizFontsNet.dll

Step 2. Add the following controls to your form:

  • 1. TextBox (textBox1) - text input, will be converted to barcode
  • 2. Button (button1) - to trigger the conversion. Set its Text property to "Encode"
  • 3. Label (label1) - to display the encoded barcode
Add controls to the form

Step 3. Edit the label properties

  • Set the Font to BCW_Code128B_2, 24pt
  • Set UseMnemonic to False
Adjust the font properties of the label

Step 4. Add code to convert the text to barcode

  • Double-click on button1 and add the following code in the Click event:
    Code128Fonts encoder = new Code128Fonts();
    label1.Text = encoder.Code128B(textBox1.Text);
  • Add a using directive:
    using BarCodeWizFontsNet;
Convert text to Code 128 B in C#
  • The final result
Code 128 B Font in a label with C#

See More

  • To see a more advanced example of barcode printing and label formatting with Code 128 Barcode Fonts in C#, open the project:
    Documents\BarCodeWiz Examples\Code 128 Barcode Fonts\DotNet\CSHARP