提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
原创|使用教程|编辑:龚雪|2021-09-07 10:08:57.387|阅读 343 次
概述:本文主要介绍如何在打印/导出时设置纸张格式,并向报表添加自定义信息,欢迎下载最新版体验!
#慧都22周年庆大促·界面/图表报表/文档/IDE/IOT/测试等千款热门软控件火热促销中>>
相关链接:
WinForm平台下的DevExpress Reporting控件允许您自定义纸张格式、方向,并将自定义信息添加到报表中。请注意,以下方法适用于实现 IPrintable 接口的控件(例如 XtraGrid、XtraPivotGrid、XtraScheduler、XtraTreeList、XtraCharts、Layout Control、XtraVerticalGrid 等)。
获取工具下载 - DevExpress WinForm v21.1
要开始学习本教程,请启动Microsoft Visual Studio并创建一个新的Windows Forms应用程序或打开一个现有应用程序,然后运行Toolbox并将实现接口所需控件拖放到窗体上。
接下来,您可以将控件绑定到数据或手动填充它。
IPrintable接口允许您自定义打印设置并使用 PrintableComponentLink 打印控件,以下代码演示了如何创建 PrintableComponentLink、将控件分配给其 PrintableComponentLinkBase.Component 属性、调整其打印设置以及打印控件。
C#
using DevExpress.LookAndFeel;
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting;
using DevExpress.XtraPrinting.Links;
using DevExpress.XtraPrintingLinks;
//...
public partial class Form1 : XtraForm {
//...
private void gridControl1_Load(object sender, EventArgs e) {
PreviewPrintableComponent(gridControl1, gridControl1.LookAndFeel);
}
void PreviewPrintableComponent(IPrintable component, UserLookAndFeel lookAndFeel) {
// Create a link that will print a control.
PrintableComponentLink link = new PrintableComponentLink() {
PrintingSystemBase = new PrintingSystemBase(),
Component = component,
Landscape = true,
PaperKind = PaperKind.A5,
Margins = new Margins(20,20,20,20)
};
// Show the report.
link.ShowRibbonPreview(lookAndFeel);
}
}
VB.NET
Imports DevExpress.LookAndFeel
Imports DevExpress.XtraEditors
Imports DevExpress.XtraPrinting
Imports DevExpress.XtraPrinting.Links
Imports DevExpress.XtraPrintingLinks
'...
Public Partial Class Form1
Inherits XtraForm
'...
Private Sub gridControl1_Load(sender As Object, e As EventArgs)
PreviewPrintableComponent(gridControl1, gridControl1.LookAndFeel)
End Sub
Private Sub PreviewPrintableComponent(component As IPrintable, lookAndFeel As UserLookAndFeel)
' Create a link that will print a control.
Dim link As New PrintableComponentLink() With { _
.PrintingSystemBase = New PrintingSystem(), _
.Component = component, _
.Landscape = True, _
.PaperKind = PaperKind.A5, _
.Margins = New Margins(20, 20, 20, 20) _
}
' Show the report.
link.ShowRibbonPreview(lookAndFeel)
End Sub
End Class
创建报表页眉或者页脚来向报表添加自定义信息,订阅CreateReportHeader事件来添加报表头,如下所示。
C#
using DevExpress.LookAndFeel;
using DevExpress.XtraEditors;
using DevExpress.XtraPrinting;
using DevExpress.XtraPrinting.Links;
using DevExpress.XtraPrintingLinks;
//...
public partial class Form1 : XtraForm {
//...
void PreviewPrintableComponent(IPrintable component, UserLookAndFeel lookAndFeel) {
// Create a link that will print a control.
//...
// Subscribe to the CreateReportHeaderArea event used to generate the report header.
link.CreateReportHeaderArea += link_CreateReportHeaderArea;
// Show the report.
link.ShowRibbonPreview(lookAndFeel);
}
}
VB.NET
Imports DevExpress.LookAndFeel Imports DevExpress.XtraEditors Imports DevExpress.XtraPrinting Imports DevExpress.XtraPrinting.Links Imports DevExpress.XtraPrintingLinks '... Public Partial Class Form1 Inherits XtraForm '... Private Sub PreviewPrintableComponent(component As IPrintable, lookAndFeel As UserLookAndFeel) ' Create a link that will print a control. '... ' Subscribe to the CreateReportHeaderArea event used to generate the report header. AddHandler link.CreateReportHeaderArea, AddressOf Link_CreateReportHeaderArea ' Show the report. link.ShowRibbonPreview(lookAndFeel) End Sub End Class
按如下方式处理 CreateReportHeader 事件。
C#
using System.Drawing;
using DevExpress.XtraPrinting;
private void link_CreateReportHeaderArea(object sender,
CreateAreaEventArgs e) {
string reportHeader = "Categories Report";
e.Graph.StringFormat = new BrickStringFormat(StringAlignment.Center);
e.Graph.Font = new Font("Tahoma", 14, FontStyle.Bold);
RectangleF rec = new RectangleF(0, 0, e.Graph.ClientPageSize.Width, 50);
e.Graph.DrawString(reportHeader, Color.Black, rec, BorderSide.None);
}
VB.NET
Imports System.Drawing
Imports DevExpress.XtraPrinting
Private Sub link_CreateReportHeaderArea(ByVal sender As System.Object, _
ByVal e As CreateAreaEventArgs) _
Handles PrintableComponentLink1.CreateReportHeaderArea
Dim reportHeader As String = "Categories Report"
e.Graph.StringFormat = New BrickStringFormat(StringAlignment.Center)
e.Graph.Font = New Font("Tahoma", 14, FontStyle.Bold)
Dim rec As RectangleF = New RectangleF(0, 0, e.Graph.ClientPageSize.Width, 50)
e.Graph.DrawString(reportHeader, Color.Black, rec, BorderSide.None)
End Sub
下图说明了包含指定打印选项和附加自定义信息的结果报表。
除了打印预览窗口中提供的导出功能外,您还可以通过PrintableComponentLink对象导出报表。
C#
PrintableComponentLink link = new PrintableComponentLink(); link.ExportToPdf(@"c:\gridcontrol.pdf");
VB.NET
Dim link As New PrintableComponentLink()
link.ExportToPdf("c:\gridcontrol.pdf")
DevExpress WinForm拥有180+组件和UI库,能为Windows Forms平台创建具有影响力的业务解决方案。DevExpress WinForms能完美构建流畅、美观且易于使用的应用程序,无论是Office风格的界面,还是分析处理大批量的业务数据,它都能轻松胜任!
更多产品正版授权详情及优惠,欢迎咨询
DevExpress技术交流群4:715863792 欢迎一起进群讨论
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@hmdbvip.cn
文章转载自:慧都网



在现代软件开发过程中,自动化单元测试是确保代码质量与可靠性的关键环节。尤其对于特定框架(如MFC)的代码,测试复杂度显著增加,常因依赖外部资源或交互操作而难以在静默环境中顺利执行。Parasoft C/C++test作为专业的软件测试工具,致力于帮助开发团队高效实施自动化测试,通过其强大的桩函数功能,能够有效模拟依赖组件的行为,从而实现对复杂逻辑的隔离测试。
本文将为大家介绍如何在MyEclipse中使用XDoclet开发EJB 2 Session Bean,欢迎下载最新版体验!
如果能将 CSV 自动转换为 PDF ,就能快速生成清晰、美观的报表,既节省手动排版时间,又能保持数据的专业呈现。本文将介绍如何使用 Spire.XLS for Java 实现这一过程——从加载 CSV 到输出高质量 PDF,仅需数行代码即可完成。
Parasoft C/C++test是一款专为C/C++代码设计的自动化测试工具,通过静态代码分析、单元测试和运行时错误检测等功能,帮助开发团队在早期发现并修复缺陷,提升代码质量和开发效率 。在实际使用中,尤其是在VC6此类旧版开发环境中执行单元测试时,可能会因环境兼容性问题触发链接错误。
相关产品
优秀的界面控件开发包,帮助企业构建卓越应用!
DevExpress WinForms Subscription为Windows Forms平台创建具有影响力的业务解决方案,高性价比WinForms界面控件套包。
DevExpress DXperience Subscription高性价比的企业级.NET用户界面套包,助力企业创建卓越应用!
最新文章 MORE
永利最大(官方)网站相关的文章 MORE
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@hmdbvip.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢
永利最大(官方)网站 