博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
XtraReport 一张纸打印3条记录
阅读量:4576 次
发布时间:2019-06-08

本文共 2527 字,大约阅读时间需要 8 分钟。

首先创建二个XtraReport一个是主一个是从

主:在Detail里面加三个xrSubreport控件

View Code
///         /// 打印        ///         /// 数据集         /// 打印机名称        public NewSuNingReport(DataTable dt1, DataTable dt2, DataTable dt3, string PrinterName)        {            InitializeComponent();             if (dt1!=null)            {                SuNingReport sunrep1 = new SuNingReport(dt1);                this.xrSubreport1.ReportSource = sunrep1;            }            if (dt2 != null)            {                SuNingReport sunrep2 = new SuNingReport(dt2);                this.xrSubreport2.ReportSource = sunrep2;            }            if (dt3 != null)            {                SuNingReport sunrep3 = new SuNingReport(dt3);                this.xrSubreport3.ReportSource = sunrep3;            }            this.PrinterName = PrinterName;            this.Print();        }

 

从里面设置好你的报表格式绑定好数据

View Code
public SuNingReport(DataTable dt)        {            InitializeComponent();            if (dt != null && dt.Rows.Count > 0)            {                this.xrBarCode1.Text = dt.Rows[0]["订单1"].ToString();                this.xrBarCode2.Text = dt.Rows[0]["订单2"].ToString();                this.xrLabel2.Text = String.Format("共 {0} 箱", dt.Rows[0]["共几箱"].ToString());                this.xrLabel3.Text = String.Format("第 {0} 箱", dt.Rows[0]["第几箱"].ToString());                this.DetailReport.DataSource = dt;                this.xrTableCell5.DataBindings.Add("Text", dt, "商品编号");                this.xrTableCell6.DataBindings.Add("Text", dt, "商品名称");                this.xrTableCell7.DataBindings.Add("Text", dt, "商品数量");                this.xrTableCell8.DataBindings.Add("Text", dt, "商品库位");            }        }

调用方法

View Code
for (int j = 0; j < ds.Tables.Count; j = j + 3)                    {                        DataTable dt1 = null;                        DataTable dt2 = null;                        DataTable dt3 = null;                        if (count > j)                        {                            dt1 = ds.Tables[j];                        }                        if (count > j + 1)                        {                            dt2 = ds.Tables[j + 1];                        }                        if (count > j + 2)                        {                            dt3 = ds.Tables[j + 2];                        }                        NewSuNingReport suning = new NewSuNingReport(dt1, dt2, dt3, PrinterName);                    }

转载于:https://www.cnblogs.com/freexiaoyu/archive/2012/10/18/2729377.html

你可能感兴趣的文章
5 OK6410裸机调试(不用Jlink)
查看>>
“模板”学习笔记(5)-----编译器在处理函数模板的时候都干了啥
查看>>
教你用shell写CGI程序
查看>>
窗口 对话框 Pop Dialog 示例
查看>>
ubuntu(centos) server安装vmware tools
查看>>
数据结构之最大不重复串
查看>>
为什么要配置sdk-tools/platform-toools?
查看>>
自己动手开发更好用的markdown编辑器-07(扩展语法)
查看>>
maven dependency:tree中反斜杠的含义
查看>>
队列的循环队列
查看>>
程序中的日期格式
查看>>
大众点评CAT错误总结以及解决思路
查看>>
从0开始学爬虫3之xpath的介绍和使用
查看>>
vim下正则表达式的非贪婪匹配
查看>>
一个python的计算熵(entropy)的函数
查看>>
spring源码学习——spring整体架构和设计理念
查看>>
模拟window系统的“回收站”
查看>>
报文格式【定长报文】
查看>>
RDLC报表钻取空白页问题
查看>>
多路电梯调度的思想
查看>>