C#调用codesoft模板打印条码
C#初学者,因近期要用到条码打印,便从网上找了些资料来学习,但在实际支行程序却得到“未将对象引用设置到对象的实例”。附件是源代码和打印模板,请高手指点一二,谢谢!using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LabelManager2;//已安装好CodeSoft 6.0,并在“引用”中引用了Lppx2.tlb
namespace WindowsFormsApplication10
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
ApplicationClass lbl = new ApplicationClass();
try
{
lbl.Documents.Open(@"D:\222.Lab", false);// 调用设计好的label文件
Document doc = lbl.ActiveDocument;
doc.Variables.FormVariables.Item("Var0").Value = txtContent1.Text.Trim(); //给参数传值
doc.Variables.FormVariables.Item("Var1").Value = txtContent2.Text.Trim(); //给参数传值
int Num = Convert.ToInt32(txtQuentity.Text); //打印数量
doc.PrintDocument(Num); //打印
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
lbl.Quit(); //退出
}
}
}
}
WindowsFormsApplication10.rar
(81 KB)