C# 生成和读取条形码、二维码

C# 生成和读取条形码、二维码_第1张图片

1.首先,需要安装ZXing.Net库,可以通过NuGet包管理器进行安装:

2.引用文件

using System;

using System.Drawing;

using ZXing;

3.各个控件按照上面的名称进行命名

4.以下是代码:

生成代码:

 private void button1_Click(object sender, EventArgs e)
 {
     try
 {
         Height = Convert.ToInt32(textBox3_Height.Text.Trim());
         Width = Convert.ToInt32(textBox2_Width.Text.Trim());
        if ((Code_txt.Text.Trim() != "") && radioButton2.Checked == true)
        {
             Code_txt.MaxLength = 12;
             //设置条形码规格
             EncodingOptions encoding = new EncodingOptions();

             //设置宽高
             encoding.Height = Height;
         

你可能感兴趣的:(c#,开发语言)