DevExpress表格打印预览及自定义页眉页脚并绘制图片(C# Winform)
DevExpress表格打印预览及自定义页眉页脚并绘制图片(C# Winform)
C# Code:
private static void OnClick_PrintFile(object sender, EventArgs e)
{
GridControl gc = _Current.GridView.GridControl; //绑定表格组件
GridView gv = _Current.GridView;
gv.OptionsPrint.AutoWidth = false;
//实例化打印组件
PrintableComponentLink link = new PrintableComponentLink(new PrintingSystem());
link.Component = gc;
link.Landscape = true;
link.PaperKind = System.Drawing.Printing.PaperKind.A4;
link.CreateMarginalHeaderArea = Link_CreateMarginalHeaderArea;
link.CreateDocument();
link.ShowPreview();
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
private static void OnClick_PrintFile(object sender, EventArgs e)
{
GridControl gc = _Current.GridView.GridControl; //绑定表格组件
GridView gv = _Current.GridView;
gv.OptionsPrint.AutoWidth = false;
//实例化打印组件
PrintableComponentLink link = new PrintableComponentLink(new PrintingSystem());
link.Component = gc;
link.Landscape = true;
link.PaperKind = System.Drawing.Printing.PaperKind.A4;
link.CreateMarginalHeaderArea = Link_CreateMarginalHeaderArea;
link.CreateDocument();
link.ShowPreview();
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
C# Code:
private static void Link_CreateMarginalHeaderArea(object sender, CreateAreaEventArgs e)
{
GridControl gc = _Current.GridView.GridControl; //绑定表格组件
//LOGO
e.Graph.DrawImage(global::UYouTMS.Library.Properties.Resources.firs_logo2,
new RectangleF(0, 0, 110, 57), DevExpress.XtraPrinting.BorderSide.None, Color.White);
//报表标题
string title = gc.FindForm().Text;
title = "上海飞升国际物流有限公司 《" title "》";
PageInfoBrick brick = e.Graph.DrawPageInfo(PageInfo.None, title, Color.Black,
new RectangleF(120, 0, 400, 30), DevExpress.XtraPrinting.BorderSide.None);
brick.LineAlignment = BrickAlignment.Center;
brick.Alignment = BrickAlignment.Center;
brick.AutoWidth = false;
brick.Font = new Font("黑体", 13f, FontStyle.Bold);
//打印时间信息
string text = String.Format("打印人:{0} 打印时间:{1}",
Loginer.CurrentUser.AccountName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
DevExpress.XtraPrinting.PageHeaderFooter P = new PageHeaderFooter();
P.Footer.Content.Add(text);
P.Footer.LineAlignment = BrickAlignment.Center;
(sender as PrintableComponentLink).PageHeaderFooter = P;
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
private static void Link_CreateMarginalHeaderArea(object sender, CreateAreaEventArgs e)
{
GridControl gc = _Current.GridView.GridControl; //绑定表格组件
//LOGO
e.Graph.DrawImage(global::UYouTMS.Library.Properties.Resources.firs_logo2,
new RectangleF(0, 0, 110, 57), DevExpress.XtraPrinting.BorderSide.None, Color.White);
//报表标题
string title = gc.FindForm().Text;
title = "上海飞升国际物流有限公司 《" title "》";
PageInfoBrick brick = e.Graph.DrawPageInfo(PageInfo.None, title, Color.Black,
new RectangleF(120, 0, 400, 30), DevExpress.XtraPrinting.BorderSide.None);
brick.LineAlignment = BrickAlignment.Center;
brick.Alignment = BrickAlignment.Center;
brick.AutoWidth = false;
brick.Font = new Font("黑体", 13f, FontStyle.Bold);
//打印时间信息
string text = String.Format("打印人:{0} 打印时间:{1}",
Loginer.CurrentUser.AccountName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
DevExpress.XtraPrinting.PageHeaderFooter P = new PageHeaderFooter();
P.Footer.Content.Add(text);
P.Footer.LineAlignment = BrickAlignment.Center;
(sender as PrintableComponentLink).PageHeaderFooter = P;
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网