Create Barcodes with C# WinForms
Step 1. Add a Reference to BarCodeWizFonts.Code128.dll
- Click on Project > Add Reference...
![](https://media.barcodewiz.com/images/f4598897-e813-4aab-add8-c5c274c1fecc-csharp1.png)
- Click Browse...
![](https://media.barcodewiz.com/images/17a28531-ca6f-489e-9b06-96c4525d3abd-csharp2.png)
- Locate BarCodeWizFonts.Code128.dll and click Add. The default location is:
C:\Program Files\BarCodeWiz\BarCodeWiz Code 128 Fonts\DotNet\net40 (use with .NET 4.0 or newer)
C:\Program Files\BarCodeWiz\BarCodeWiz Code 128 Fonts\DotNet\net20 (use with .NET 2.0 or newer)
![](https://media.barcodewiz.com/images/393637f9-afff-4915-b668-37c0d49bacd3-dotNetBrowseReference_1.png)
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
![](https://media.barcodewiz.com/images/398ec81c-d84c-4aaf-85bc-cfb3728c48f5-csharp7.png)
Step 3. Edit the label properties
- Set the Font to BCW_Code128B_2, 24pt
- Set UseMnemonic to False
![](https://media.barcodewiz.com/images/c13c4b5d-2399-48ce-9d1f-50616d8acdde-csharp4.png)
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 BarCodeWizFonts.Code128;
![](https://media.barcodewiz.com/images/c0e3ca29-fcee-4c43-a6b8-55535f90ac95-csharp5_1.png)
- The final result
![](https://media.barcodewiz.com/images/325de6dc-0ca2-410e-8301-9619adbbd370-csharp6.png)
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
![](https://media.barcodewiz.com/images/8487fe26-894b-4751-8a67-afb5e3d5434d-csharp8.png)