Tuesday, 1 September 2015

Generate Barcode in Windows Application

Generate Barcode in Windows Application


1st Step:--Take Window Form Application

2nd Step :-- After Designing the form Then Write Code for the Generate Barcode.

 
SOURCE CODE :-----

 private void btnGenerate_Click(object sender, EventArgs e)
        {
            string barcode = txtID.Text;

            Bitmap bitm = new Bitmap(barcode.Length * 45, 160);
            using (Graphics graphic = Graphics.FromImage(bitm))
            {


                Font newfont = new Font("IDAutomationHC39M", 20);
                PointF point = new PointF(2f, 2f);
                SolidBrush black = new SolidBrush(Color.Black);
                SolidBrush white = new SolidBrush(Color.White);
                graphic.FillRectangle(white, 0, 0, bitm.Width, bitm.Height);
                graphic.DrawString("*" + barcode + "*", newfont, black, point);
            }
            using (MemoryStream Mmst = new MemoryStream())
            {


                bitm.Save("ms", ImageFormat.Jpeg);
                pictureBox1.Image = bitm;
                pictureBox1.Width = bitm.Width;
                pictureBox1.Height = bitm.Height;
            }  
  
        }

Note :- Download the font "IDAutomationHC39M" from the Google/another Source.


3rd Step :-- Run the Application after the complete of write the Code.

4th Step :-- Insert Values into the TextBox....Then Click on button.


5th Step :-- Enjoy with this Applicatrion.......



No comments:

Post a Comment

Factorial of a Number

Recently Viewed