winform遍历bartender_C#怎么调用bartender软件

本文介绍如何在C# Winform应用中调用Bartender软件进行标签打印。通过源代码示例展示了如何设置和打印标签,以及在文本框输入后按Enter键触发打印事件。
摘要由CSDN通过智能技术生成

编写源代码,我这里附上全部源代码供参考。

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.Runtime.InteropServices;

namespace BlueTooth

{

public partial class Form1 : Form

{

string PalletID1;

public static BarTender.Application btapp1;

public static BarTender.Format btFormat1;

public Form1()

{

InitializeComponent();

}

private void BasicSet1()

{

string str1 = System.Windows.Forms.Application.StartupPath + "\\bluet.btw";

btapp1 = new BarTender.ApplicationClass();

btFormat1 = btapp1.Formats.Open(str1, false, "");

}

private void Form1_Load(object sender, EventArgs e)

{

BasicSet1();

}

public void PrintLabel(string PalletID1)

{

btFormat1.SetNamedSubStringValue("TEST", PalletID1);

btFormat1.IdenticalCopiesOfLabel = 1;

btFormat1.PrintOut(false, false);

}

private void print(string label)

{

PalletID1 = textBox1.Text.Trim();

PrintLabel(PalletID1);

}

private void button1_Click(object sender, EventArgs e)

{

print(textBox1.Text.Trim());

}

private void textBox1_KeyDown(object sender, KeyEventArgs e)

{

if (e.KeyCode == Keys.Enter)

{

print(textBox1.Text.Trim());

textBox1.SelectAll();

}

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值