INTRODUCTION
In this article, I am going to explain how to generate Barcode and QRcode in a Windows.Forms Application using Visual Studio 2017.
STEP 1 - Start the Project
Let us start the project. Open Visual Studio2017--->Start New Project--->Windows.Forms Application and name it BarcodeSample.
In this article, I am going to explain how to generate Barcode and QRcode in a Windows.Forms Application using Visual Studio 2017.
STEP 1 - Start the Project
Let us start the project. Open Visual Studio2017--->Start New Project--->Windows.Forms Application and name it BarcodeSample.

STEP 2 - Drag and Drop Controls onto the form
By default, the Designer page will get opened. Now, drag and drop controls like Picture Box, TextBox, Label and Buttons from the ToolBox onto the form in Visual Studio 2017.
Change the border style of Picture Box as Fixed 3D so that the PictureBox looks like the below screenshot. Change the text of the buttons to Barcode and QRCode. Change the text of the labels as corresponding to the buttons as Barcode and QRcode. After changing the properties of the Control, the form looks like this.
STEP 3 - Download and Install Zen Barcode Framework from Nuget Packages
For generating the Barcode and QRCode, we need to download and install Zen Barcode Framework from NuGet packages. Click project----> Manage NuGet Packages--->Browse Zen Barcode Framework---->Download and install Zen Barcode FrameWork.
STEP 4 - Coding for the Button Click Event
Follow the code given below in the screenshot for generating the Barcode and QRCode in Windows.Forms using Visual Studio 2017.
By default, the Designer page will get opened. Now, drag and drop controls like Picture Box, TextBox, Label and Buttons from the ToolBox onto the form in Visual Studio 2017.
Change the border style of Picture Box as Fixed 3D so that the PictureBox looks like the below screenshot. Change the text of the buttons to Barcode and QRCode. Change the text of the labels as corresponding to the buttons as Barcode and QRcode. After changing the properties of the Control, the form looks like this.
STEP 3 - Download and Install Zen Barcode Framework from Nuget Packages
For generating the Barcode and QRCode, we need to download and install Zen Barcode Framework from NuGet packages. Click project----> Manage NuGet Packages--->Browse Zen Barcode Framework---->Download and install Zen Barcode FrameWork.

STEP 4 - Coding for the Button Click Event
Follow the code given below in the screenshot for generating the Barcode and QRCode in Windows.Forms using Visual Studio 2017.
- private void button1_Click(object sender, EventArgs e)
- {
- Zen.Barcode.Code128BarcodeDraw barcode = Zen.Barcode.BarcodeDrawFactory.Code128WithChecksum;
- pictureBox1.Image = barcode.Draw(textBox1.Text, 50);
- }
- private void button2_Click(object sender, EventArgs e)
- {
- Zen.Barcode.CodeQrBarcodeDraw qrcode = Zen.Barcode.BarcodeDrawFactory.CodeQr;
- pictureBox1.Image = qrcode.Draw(textBox2.Text, 50);
- }

STEP 5 - Output for the Project
Compile and Run the code. The following output will be obtained. Enter some text in the text box corresponding to the Barcode Label. Now, the Barcode is generated in the PictureBox for the text entered in the Textbox when the Barcode Button is clicked.
Compile and Run the Code. The following output will be obtained. Enter some text in Textbox corresponding to the QRcode Label. Now, the QRcode is generated in the PictureBox for the text entered in the Textbox when the QRcode Button is clicked.
Summary
Hence, Barcode and QRcode are generated for the text entered in the Textbox. I hope you find this article interesting. In my next article, I will explain how to work with Tab Control in Windows.Forms using Visual Studio 2017. In case of any error or problem with the code, feel free to comment.
Summary
Hence, Barcode and QRcode are generated for the text entered in the Textbox. I hope you find this article interesting. In my next article, I will explain how to work with Tab Control in Windows.Forms using Visual Studio 2017. In case of any error or problem with the code, feel free to comment.

soenglay ucbPosted Jan 30, 2023, 9:44 AM
i got this when input string 127 characters to generate qr code An unhandled exception of type 'System.IndexOutOfRangeException' occurred in Zen.Barcode.Core.dllAdditional information: Index was outside the bounds of the array.
Shaiwal TripathiPosted Jun 9, 2022, 6:11 AM
It's not working with small picturebox.
Ayman KhoshoueyPosted Mar 20, 2021, 9:25 AM
Thanks a lot, but how to edit multi lines text?
Jerry KowalskiPosted Jan 23, 2021, 12:58 AM
Thank you! exactly what I needed
Alice NguyenPosted Jan 28, 2019, 1:14 AM
I Glad found it helpful,
sameer morePosted Nov 5, 2018, 5:52 AM
Hii i got error if i am passing greater then 200 character
Saroj Kumar SahuPosted Aug 18, 2018, 7:20 AM
Nice article
Rajanikant HawaldarPosted Aug 1, 2018, 12:44 PM
Hi how to achieve the same without third-party API
Menaka Priyadharshini BPosted Jul 30, 2018, 2:49 AM
Thank you for your comment
Sanjit Kumar SinghPosted Jul 29, 2018, 3:25 PM
Awesome Article, keep it up !!