zoukankan      html  css  js  c++  java
  • 通用表格打印 示例

    //本示例需要通用表格打印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)
    {
    //在此可以校正打印的内容和格式

    }


    }
    }

  • 相关阅读:
    Beyond Compare保存快照和CRC比较相结合的方法
    如何在Beyond Compare文本比较时设置书签
    如何使用Navicat for SQLite 触发器
    Navicat Premium 中实用工具介绍
    Beyond Compare查看合并文本后相同内容的方法
    Marriage Match II HDU
    Escape HDU
    kebab HDU
    Task Schedule HDU
    网络流深入
  • 原文地址:https://www.cnblogs.com/lhj588/p/2743151.html
Copyright © 2011-2022 走看看