原創|其它|編輯:郝浩|2012-09-14 15:58:13.000|閱讀 1029 次
概述:實現的功能:預覽的時候數據和格式都可以看到,打印的時候只打印數據,這應該是套打功能最基本的要求。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
實現的功能:預覽的時候數據和格式都可以看到,打印的時候只打印數據,這應該是套打功能最基本的要求。
基本思路:使用工具欄的printbarmanager控件,在printcontrol中顯示XtraReports。創建兩個XtraReport,一個是完整顯示(xr),另一個只顯示部分數據(xr_report)。打印的時候在printcontrol中顯示xr_report,xr_report打印完畢時(PrintingSystem.EndPrint事件)換回xr。
關鍵點:設置xtrareport的格式后,還要執行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;
}
}
}
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:轉自CSDN 作者gaomicro