List of Exercises

How to Create Generate Barcode in WinForms C#

	    
using IronBarCode;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Generate_Bacode
{
  public partial class Form1 : Form
  {
    // NuGet\Install-Package BarCode -Version 2020.5.0
    GeneratedBarcode MyBarCode;
    public Form1()
    {
      InitializeComponent();
    }

    private void to_barcode_Click(object sender, EventArgs e)
    {
      MyBarCode = IronBarCode.BarcodeWriter.CreateBarcode(
        textBox_url.Text, BarcodeWriterEncoding.Code128);
      pictureBox1.Image = MyBarCode.Image;
    }
    public byte[] ImageToByteArray(System.Drawing.Image imageIn)
    {
      using (var ms = new MemoryStream())
      {
        imageIn.Save(ms,System.Drawing.Imaging.ImageFormat.Jpeg);
        return ms.ToArray();
      }
    }

    private void to_string_Click(object sender, EventArgs e)
    {
      var barcode = BarcodeReader.QuicklyReadOneBarcode((Bitmap)pictureBox1.Image);
      textBox_url.Text = barcode.ToString();
    }

    private void save_barcode_Click(object sender, EventArgs e)
    {
      SaveFileDialog sfd = new SaveFileDialog();
      sfd.Filter = "Jpeg|*.jpg";
      if (sfd.ShowDialog() == DialogResult.OK)
      {
        MyBarCode.SaveAsJpeg(sfd.FileName);
        MessageBox.Show("It Saved.");
      }
    }
  }
}
		
	 


Download the project of Visual Studio 2013 in DropBox Download


How to Generate Barcode in WinForms C# | URL to BarCode


Video Thumbnail