原創(chuàng)|其它|編輯:郝浩|2012-09-14 15:58:13.000|閱讀 1029 次
概述:實(shí)現(xiàn)的功能:預(yù)覽的時(shí)候數(shù)據(jù)和格式都可以看到,打印的時(shí)候只打印數(shù)據(jù),這應(yīng)該是套打功能最基本的要求。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷(xiāo)售中 >>
實(shí)現(xiàn)的功能:預(yù)覽的時(shí)候數(shù)據(jù)和格式都可以看到,打印的時(shí)候只打印數(shù)據(jù),這應(yīng)該是套打功能最基本的要求。
基本思路:使用工具欄的printbarmanager控件,在printcontrol中顯示XtraReports。創(chuàng)建兩個(gè)XtraReport,一個(gè)是完整顯示(xr),另一個(gè)只顯示部分?jǐn)?shù)據(jù)(xr_report)。打印的時(shí)候在printcontrol中顯示xr_report,xr_report打印完畢時(shí)(PrintingSystem.EndPrint事件)換回xr。
關(guān)鍵點(diǎn):設(shè)置xtrareport的格式后,還要執(zhí)行CreateDocument()
代碼如下:
using 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 DevExpress.XtraEditors;
using DevExpress.XtraReports.UI;
using DevExpress.XtraPrinting.Preview;
using DevExpress.XtraPrinting;
using DevExpress.XtraPrinting.Control;
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
XtraReport1 xr = new XtraReport1();
XtraReport1 xr_other = new XtraReport1();
public Form1()
{
InitializeComponent();
xr_other.PrintingSystem.EndPrint += new EventHandler(PrintingSystem_EndPrint);
}
void PrintingSystem_EndPrint(object sender, EventArgs e)
{
printControl1.PrintingSystem = xr.PrintingSystem;
}
private void Form1_Load(object sender, EventArgs e)
{
printControl1.PrintingSystem = xr.PrintingSystem;
xr.CreateDocument();
xr_other.xrTable1.Borders = BorderSide.None;
xr_other.xrLabel1.Visible = false;
xr_other.CreateDocument();
}
private void printPreviewBarItem9_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
printControl1.PrintingSystem = xr_other.PrintingSystem;
}
private void printPreviewBarItem8_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
printControl1.PrintingSystem = xr_other.PrintingSystem;
}
}
}
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:轉(zhuǎn)自CSDN 作者gaomicro