通用表格打印 示例

//本示例需要通用表格打印1或2,以及接口和Code128条码生成一起使用

sing 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 cyh.General;


namespace DemoTableXReport
{
    public partial class Form1 : Form
    {
        private DataSet dataSet1;
        public Form1()
        {
            InitializeComponent();

        }

        private void Form1_Load(object sender, EventArgs e)
        {

            //读入数据到dataSet
            dataSet1 = new DataSet();
            dataSet1.ReadXml(Application.StartupPath+ "\\testReport.xml", System.Data.XmlReadMode.ReadSchema);
            dataGridView1.DataSource = dataSet1;
            dataGridView1.DataMember = dataSet1.Tables[0].TableName;                       
        }

        private void button1_Click(object sender, EventArgs e)
        {
            iTableReport xtr = new ctlTableReport();
            xtr.AddReportTitle("测试上1(center)", true, null, StringAlignment.Center, Size.Empty);
            xtr.AddReportTitle("测试上2(far)", true, null, StringAlignment.Far, Size.Empty);
            xtr.AddReportTitle("测试下1(center)", false, null, StringAlignment.Center, Size.Empty);
            xtr.AddReportTitle("测试下2(near){0}", false);
            xtr.AddReportField("编   号", null, "药品目录", StringAlignment.Near, null, false, string.Empty, true, string.Empty, Size.Empty);
            xtr.AddReportField("名        称", "名称");
            xtr.AddReportField("规      格2", null, "规格", StringAlignment.Near, null, false, "合计", false, string.Empty, Size.Empty);
            xtr.AddReportField("零   售    价3", null, "零售价", StringAlignment.Far, null, false, "", true, "{0:#0.00}", Size.Empty);
            xtr.SetReportBarCode("A202010", new Point(100, 0), new Size(500, 100), true, string.Empty);
            //int r = xtr.GetAutoRow(dataSet1.Tables[0].Rows.Count, 40);
            //xtr.SetReportMain(100, r, ReportGridLine.Nothing, StringAlignment.Center, false, new System.Drawing.Printing.Margins(80, 80, 100, 80), System.Drawing.Printing.PaperKind.Custom, Size.Empty, 1, 0, "", true, 1);
            xtr.SetReportMain(100, 20, ReportGridLine.Nothing, StringAlignment.Center, false, new System.Drawing.Printing.Margins(80, 80, 100, 80), System.Drawing.Printing.PaperKind.Custom, Size.Empty, 1, 0, "", false , 1);           
            xtr.UnitAfterPrint += new ReportUnitAfterPrint(xtr_UnitAfterPrint);
            xtr.DataSource = dataSet1.Tables[0];           
            xtr.ShowDialog();    
        }
        void xtr_UnitAfterPrint(object sender, ReportBandType source, int PageIndex, int RowIndex, string Caption, string Field, ref string Value, EventArgs e)
        {

            //if (source == ReportBandType.PageFooder)
            //   Value = string.Format("{0}",PageIndex+1);
            //throw new NotImplementedException();
        }
        void xtr_UnitAfterPrint(object sender, int source, int PageIndex, int RowIndex, string Caption, string Field, ref string Value, EventArgs e)
        {
            //在此可以校正打印的内容和格式

        }

      
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值