原創(chuàng)|其它|編輯:郝浩|2012-10-12 17:24:39.000|閱讀 1828 次
概述:這個(gè)章節(jié)內(nèi)容詳細(xì)說(shuō)明《DevExpress開(kāi)發(fā)教程之報(bào)表打印設(shè)計(jì)實(shí)現(xiàn)篇》中的關(guān)鍵代碼部分、簡(jiǎn)單的設(shè)計(jì)和打印應(yīng)用。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
這個(gè)章節(jié)內(nèi)容詳細(xì)說(shuō)明《DevExpress開(kāi)發(fā)教程之報(bào)表打印設(shè)計(jì)實(shí)現(xiàn)篇》中的關(guān)鍵代碼部分、簡(jiǎn)單的設(shè)計(jì)和打印應(yīng)用。
1、DevExpress中可以通過(guò)report.RunDesignerDialog或者report.RunDesigner來(lái)設(shè)計(jì)報(bào)表,這里沒(méi)有使用這兩個(gè)方法來(lái)實(shí)現(xiàn)報(bào)表設(shè)計(jì)功能,而是使用第一章中的自定義的DesignReportForm來(lái)實(shí)現(xiàn)(實(shí)際上相同,但自定義可以控制其他如根據(jù)權(quán)限顯示等內(nèi)容)。
2、DesignReportForm非常簡(jiǎn)單,就是把DesignReportControl,DesignToolBar和DesignFormattingToolBar拼湊在一起,它們共同關(guān)聯(lián)designReportControl1.DesignPanel。
3、現(xiàn)在設(shè)計(jì)一個(gè)簡(jiǎn)單的DataSet,內(nèi)容如下:
DataSet ds = new DataSet("DeliveryDataSet"); DataTable dtDelivery= new DataTable("Delivery"); { dtDelivery.Columns.Add("BillId", typeof(string)); dtDelivery.Columns.Add("ManualId", typeof(string)); dtDelivery.Columns.Add("BillDate", typeof(DateTime)); dtDelivery.Columns.Add("CustomerId", typeof(string)); dtDelivery.Columns.Add("WarehouseId", typeof(string)); dtDelivery.Columns.Add("Maker", typeof(string)); dtDelivery.Columns.Add("Remark", typeof(string)); { DataRow row = dtDelivery.NewRow(); row["BillId"] = "IGZ0000002"; row["ManualId"] = "Kingmond.Demo"; row["BillDate"] = DateTime.Today; row["CustomerId"] = "Regent"; row["WarehouseId"] = "MyStore"; row["Maker"] = "kevin"; row["Remark"] = "Demo a report."; dtDelivery.Rows.Add(row); } } DataTable dtDeliveryGoods = new DataTable("DeliveryGoods"); { dtDeliveryGoods.Columns.Add("BillId", typeof(string)); dtDeliveryGoods.Columns.Add("BillGoodsId", typeof(string)); dtDeliveryGoods.Columns.Add("GoodsId", typeof(string)); dtDeliveryGoods.Columns.Add("Quantity", typeof(int)); { DataRow row = dtDeliveryGoods.NewRow(); row["BillId"] = "IGZ0000002"; row["BillGoodsId"] = "IGZ0000002001"; row["GoodsId"] = "R001"; row["Quantity"] = 23; dtDeliveryGoods.Rows.Add(row); } { DataRow row = dtDeliveryGoods.NewRow(); row["BillId"] = "IGZ0000002"; row["BillGoodsId"] = "IGZ0000002002"; row["GoodsId"] = "R002"; row["Quantity"] = 36; dtDeliveryGoods.Rows.Add(row); } } DataTable dtDeliveryDetail = new DataTable("DeliveryDetail"); { dtDeliveryDetail.Columns.Add("AutoId", typeof(int)); dtDeliveryDetail.Columns.Add("BillGoodsId", typeof(string)); dtDeliveryDetail.Columns.Add("ColorId", typeof(string)); dtDeliveryDetail.Columns.Add("GoodsLong", typeof(string)); dtDeliveryDetail.Columns.Add("S1", typeof(int)); dtDeliveryDetail.Columns.Add("S2", typeof(int)); dtDeliveryDetail.Columns.Add("S3", typeof(int)); { DataRow row = dtDeliveryDetail.NewRow(); row["AutoId"] = 1; row["BillGoodsId"] = "IGZ0000002001"; row["ColorId"] = "RED"; row["GoodsLong"] = "0"; row["S1"] = 7; row["S3"] = 11; dtDeliveryDetail.Rows.Add(row); } { DataRow row = dtDeliveryDetail.NewRow(); row["AutoId"] = 2; row["BillGoodsId"] = "IGZ0000002001"; row["ColorId"] = "WHT"; row["GoodsLong"] = "0"; row["S1"] = 2; row["S2"] = 3; dtDeliveryDetail.Rows.Add(row); } { DataRow row = dtDeliveryDetail.NewRow(); row["AutoId"] = 3; row["BillGoodsId"] = "IGZ0000002002"; row["ColorId"] = "RED"; row["GoodsLong"] = "0"; row["S1"] = 1; row["S2"] = 7; dtDeliveryDetail.Rows.Add(row); } { DataRow row = dtDeliveryDetail.NewRow(); row["AutoId"] = 4; row["BillGoodsId"] = "IGZ0000002002"; row["ColorId"] = "BLK"; row["GoodsLong"] = "0"; row["S1"] = 20; row["S2"] = 8; dtDeliveryDetail.Rows.Add(row); } } ds.Tables.Add(dtDelivery); ds.Tables.Add(dtDeliveryGoods); ds.Tables.Add(dtDeliveryDetail); //設(shè)置表之間的關(guān)系 ds.Relations.Add("Delivery_DeliveryGoods", dtDelivery.Columns["BillId"], dtDeliveryGoods.Columns["BillId"]); ds.Relations.Add("DeliveryGoods_DeliveryDetail", dtDeliveryGoods.Columns["BillGoodsId"], dtDeliveryDetail.Columns["BillGoodsId"]);
4、DataSet通過(guò)方法WriteXmlSchema(@"c:\temp\delivery.xml");可以很容易得到DataSet的Schema文件。
5、 設(shè)計(jì)delivery 報(bào)表格式,通過(guò)
ReportUtil.DesignReport (@"c:\temp\delivery.repx",@"c:\temp\delivery.xml")可以設(shè)計(jì)已經(jīng)存在的格式文件.
6、設(shè)計(jì)結(jié)果參考圖片:
7、預(yù)覽結(jié)果參考圖片:
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:博客園