ByteScout BarCode Generator SDK - C# - Display Barcode On Form - ByteScout

ByteScout BarCode Generator SDK – C# – Display Barcode On Form

  • Home
  • /
  • Articles
  • /
  • ByteScout BarCode Generator SDK – C# – Display Barcode On Form

How to display barcode on form in C# with ByteScout Barcode SDK

How to code in C# to display barcode on form with this step-by-step tutorial

This sample source code below will demonstrate you how to display barcode on form in C#. ByteScout Barcode SDK: the fully featured library to generate barcodes. Supports QR Code, Code 39, Code 128, UPC, GS1, GS-128, PDF417, Datamatrix and many other barcode types. Includes various options for barcode generation to ensure output quality, add barcodes to new or existing pdf files and images. It can display barcode on form in C#.

C# code samples for C# developers help to speed up coding of your application when using ByteScout Barcode SDK. Just copy and paste the code into your C# application’s code and follow the instruction. Code testing will allow the function to be tested and work properly with your data.

ByteScout Barcode SDK free trial version is available on our website. C# and other programming languages are supported.

Try ByteScout Barcode SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

namespace DisplayBarcodeOnForm { partial class Form1 { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.panel1 = new System.Windows.Forms.Panel(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // // pictureBox1 // this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.pictureBox1.Location = new System.Drawing.Point(12, 36); this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Size = new System.Drawing.Size(270, 270); this.pictureBox1.TabIndex = 0; this.pictureBox1.TabStop = false; // // panel1 // this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panel1.Location = new System.Drawing.Point(314, 36); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(270, 270); this.panel1.TabIndex = 1; this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(12, 9); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(179, 13); this.label1.TabIndex = 2; this.label1.Text = "Show barcode in PictureBox control:"; // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(311, 9); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(157, 13); this.label2.TabIndex = 3; this.label2.Text = "Draw barcode on Panel control:"; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(599, 349); this.Controls.Add(this.label2); this.Controls.Add(this.label1); this.Controls.Add(this.panel1); this.Controls.Add(this.pictureBox1); this.Name = "Form1"; this.Text = "Form1"; ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; } }

Try ByteScout Barcode SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

using System.Drawing; using System.Windows.Forms; using Bytescout.BarCode; // This application demonstrates two ways how you can show the barcode on a form: // 1. using PictureBox control; // 2. painting it on a Panel control. namespace DisplayBarcodeOnForm { public partial class Form1 : Form { private Barcode _barcode = null; public Form1() { InitializeComponent(); // Create Barcode Generator instance _barcode = new Barcode(); _barcode.RegistrationName = "demo"; _barcode.RegistrationKey = "demo"; // Setup barcode _barcode.Symbology = SymbologyType.QRCode; _barcode.Value = "Testing Testing Testing Testing Testing Testing Testing Testing Testing Testing Testing Testing Testing"; // Put the barcode image to PictureBox pictureBox1.Image = _barcode.GetImage(); } // Paint the barcode image on a Panel control private void panel1_Paint(object sender, PaintEventArgs e) { Image barcodeImage = _barcode.GetImage(); e.Graphics.DrawImage(barcodeImage, 0, 0); } } }

Try ByteScout Barcode SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

using System; using System.Collections.Generic; using System.Windows.Forms; namespace DisplayBarcodeOnForm { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } }

Try ByteScout Barcode SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)



Get 60 Day Free Trial or Visit ByteScout Barcode SDK Home Page

Explore ByteScout Barcode SDK Documentation

Get ByteScout Barcode SDK Free Training


Get Your Free API Key

Explore Web API Documentation