可以使用金質打印通
名稱叫:goldPrinter.dll 添加引用
代碼實現:例子,湊合看吧!金質打印通 有 源代碼,自己看懂了,可以自己寫
GoldPrinter.MisGoldPrinter webmis = new GoldPrinter.MisGoldPrinter(true); //打印组件,true為橫打,沒值為竪打
if (this.rbCampaignCode.Checked)
{
webmis.Title = this.rbCampaignCode.Text; //标题,还可设置子标题
}
else if (this.rbMediaCode.Checked)
{
webmis.Title = this.rbMediaCode.Text;
}
(webmis.Title as GoldPrinter.Title).Font = new System.Drawing.Font("", 15, System.Drawing.FontStyle.Bold);
下面这一句就可以打印DataGridView
//(webmis.Body as GoldPrinter.Body).DataSource = ToStringArray(this.dgvCode, true);
//为人特性化,自定义表体,可以设置字体、列宽、列对齐方式
GoldPrinter.Body gridBody = new GoldPrinter.Body();
//任意二维的数据通通打印,或者是设置GridText属性
gridBody.DataSource = ToStringArray(this.dgvTemp, true);
gridBody.Font = this.dgvTemp.Font;
gridBody.ColsWidth = GetColsWidth(this.dgvTemp);
webmis.Body = gridBody;
//webmis.PageSetup();
//webmis.Preview();
webmis.Print();
webmis.Dispose();
/// <summary>
/// 将VS.Net 2005 DataGridView控件的数据导出到二维数组。
/// </summary>
/// <param name="dataGridView">VS.Net 2005 DataGridView控件。</param>
/// <param name="includeColumnText">是否要把列标题文本也导到数组中。</param>
/// <