In my Previous Article's :
Generate Barcode in C#.NET
In these articles we see Creating barcode by using Windows Application in C#.NET.
General Meaning of Barcode read below.
Barcode
A machine-readable code in the form of numbers and a pattern of parallel lines of varying widths, printed on a commodity and used especially for stock control.- Before to start this Barcode Windows Application you need to "Download" and "Install" font which represents barcode language. Download Barcode Font for Free
-
After Successfully installation of barcode font, now you need to check whether the barcode font is reflected or not in Visual Studio.
- Right Click on Button and choose properties and select Font
- Open Font Windows and enter letter i in font textbox and its show similar to below image.
- Click Ok
C# Coding
C# Coding : Namespace
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; using System.Drawing.Imaging;
C# Coding : Get Barcode Button Click Event
namespace WindowsFormsApplication1 { public partial class generatebarcode : Form { public generatebarcode() { InitializeComponent(); } private void Btn_Generate_Click(object sender, EventArgs e) { string barcode = textBox1.Text; Bitmap bitmap = new Bitmap(barcode.Length * 40, 150); using (Graphics ographics = Graphics.FromImage(bitmap)) { Font oFont = new System.Drawing.Font("IDAutomationHC39M", 20); PointF point = new PointF(2f, 2f); SolidBrush oblack = new SolidBrush(Color.Black); SolidBrush owhite = new SolidBrush(Color.White); ographics.FillRectangle(owhite, 0, 0, bitmap.Width, bitmap.Height); ographics.DrawString("*" + barcode + "*", oFont, oblack, point); } using (MemoryStream ms = new MemoryStream()) { bitmap.Save(ms, ImageFormat.Png); pb_barcode.Image = bitmap; pb_barcode.Height = bitmap.Height; pb_barcode.Width = bitmap.Width; } } } }
Download Project Source Code
To Download Design and Source Code of How to Generate Barcode in C#.NET.
0 Comments