ActiveReports 区域报表中的事件介绍

本文介绍了ActiveReports中的事件处理机制,包括仅触发一次的事件(如ReportStart、DataInitialize和ReportEnd),多次触发的事件(如FetchData、PageStart和PageEnd),以及区域事件(如Format、BeforePrint和AfterPrint)。详细解释了各个事件的作用、触发时机及注意事项。

1、仅触发一次的事件

以下是在报表的处理过程中仅触发一次的所有事件这些事件在报表的处理周期中仅在最开始和结束前触发一次。

ReportStart

该事件在DataInitialize事件触发之前发生。使用此事件来初始化运行报表时需要的任何对象或者变量。还可以使用此事件设置子报表控件一个新的子报表实例。一旦该事件处理完成,不要动态的向报表动态地添加项目。

DataInitialize

该事件在ReportStart事件之后触发。使用它像报表的字段集合添加自定义字段。自定义字段可以被添加到一个绑定的报表(一个使用数据控件连接并获取记录的报表)或者一个非绑定态报表(一个不依赖数据控件获取记录的报表)。在绑定态报表中,首先打开数据集并添加数据集字段到自定义自段集合,然后触发DataInitialized事件,可以在其中添加新的自定义字段。DataInitialize事件也可以用来调整数据源或者建立数据库连接。

ReportEnd

该事件在报表处理完成时触发。使用该事件关闭或者释放您在非绑定模式使用的对象,或者向最终用户显示信息或者消息。

2、多次触发的事件

以下ActiveReports事件在报表的处理过程中多次触发。

FetchData

该事件在每次一个新的纪录处理完成时触发。FetchData具有一个EOF参数,该参数指示是否触发FetchData事件。该参数和RecordSet的EOF属性不同,默认值为True。当使用一个绑定态报表(使用数据控件的报表)时,EOF被报表自动设置,但是,当使用非绑定态报表时,该参数需要手动设置。

使用FetchData事件在非绑定报表中设置通过DataInitialize事件添加的自定义字段的值。或者在绑定报表中执行特殊功能,比如将两个字段结合或者执行计算。FetchData事件处理方法中不应当使用报表中的任何控件。

如果您希望在明细区域的一个控件上使用一个来自于数据集的值,请在FetchData事件中设置一个变量,然后在区域的Format事件中将值传递给控件。请注意,只有Detail_Format 事件支持这种用法。

此外,在使用数组或者集合时还可以使用FetchData事件递增计数器。

PageStart

该事件在一页呈现之前触发。使用该事件来初始化运行一个非绑定报表时,每个页面需要的任何变量。

PageEnd

该事件在一页呈现之后触发。使用该事件来更新运行一个非绑定报表时,每个页面需要的任何变量。

当绑定和非绑定数据值设置时

1. 绑定到报表的数据集在DataInitialize事件触发后填充字段集合。(在一个非绑定报表中,此时字段集合尚未设置。)

2. 触发FetchData事件,让用户有机会修改字段集合。

3. 所有绑定的字段的值传输完成。

4. 引发Format事件。

3、区域事件

在一份报表中,无论各种区域的内容如何,每个区域都有三个事件:

Format, BeforePrint 以及AfterPrint。

因为可能存在很多可能的报表设计,事件触发的顺序是动态的,以适应不同报表的需求。唯一可以保证的顺序是区域的Format事件会在BeforePrint事件之前触发。报表不应当设计的过度的依赖事件触发的顺序。

重要: 切勿在以上区域事件中引用报表的Fields集合。仅在DataInitialize 和 FetchData 事件中对Fields集合进行访问。

Format 事件

ActiveReports 会在数据绑定到区域包含的控件之后触发这个事件。但是会确保在区域呈现到页面上之前。

Format事件是唯一一个您可以在其中改变区域高度的事件。使用该区域对象以改变其中任何控件的属性,或者区域对象本身。

同样可以使用这个Format 事件来传递信息,比如说一个SQL字符串到子报表。

如果区域或者区域内部任何控件的 CanGrow 或者 CanShrink 属性设置为True ,所有的增长和收缩的操作在Format事件中完成。正因为如此,您无法在该事件中获取一个控件或者区间的高度的准确信息。

正是由于一个区域的高度信息在Format事件结束以前是不确定的。例如,明细区域的Format事件触发,但是计算结果表明,当前的明细区域过大,导致此页面容纳不下。这时就会导致当前页面的PageFooter事件和PageEnd事件触发。同时下一个页面的PageStart,其他的Header事件以及有可能存在的FetchData事件在该页的明细区域尚未呈现之前,提前触发。

BeforePrint 事件

ActiveReports在一个区域呈现到页面之前触发这个事件。

区域和其中的控件都已经完成了增长和收缩。因此,您可以在这个事件中获取区域和其中控件的准确高度。您可以在BeforePrint事件中改变控件的值或者尺寸,但是您不能改变区域自身的高度。

同样您可以在这个事件中做一些页面相关的格式化工作,因为在这个事件触发时,报表可以知道该区域将会呈现在哪个页面上。一旦事件处理过程完毕,区域将无法改变,因为那时区域已经在这个事件发生之后立即呈现到Canvas上。

AfterPrint 事件

ActiveReports在一个区域呈现到页面后触发这个事件。

虽然AfterPrint在ActiveReport之前的版本1的ServicePack3中间是一个重要的事件。在新版本的ActiveReports中,它已经几乎不用。然而,这个事件在某些情况下依然有用,比如您希望在页面呈现之后再对页面进行绘制。

ComponentOne 2012 V2 ActiveReports 7 ar7.zip ActiveReports 7 共三个压缩分卷,请全部下载后解压 Award-winning .NET reporting tool for Silverlight, Windows Forms, ASP.NET, and Windows Azure with an end-user Report Designer, Visual Studio integration, and more. The Preferred .NET Reporting Component with Pure Power See What's New in the ActiveReports 7 Release! Award-winning .NET Reporting tool for Silverlight, Windows Forms, ASP.NET, and Windows Azure with an End-User Report Designer, Visual Studio integration, and more. ActiveReports 7 brings Microsoft .NET developers everything from familiar Visual Studio integrated designers to extensive APIs. Create reports ranging in functionality from form-based reports such as invoices and insurance documents, to transaction reports such as sales and accounting, to analytical reports such as sales and budget analysis and portfolio analysis. Why Choose ActiveReports 7? § Multiple Report Types to Fit Your Reporting Needs § Fixed Page Layout gives developers a new way of creating reports where layout is the primary focus. Great for creating invoices, prospectus reports, forms, or other highly structured reports. § Continuous Page Layout makes it easy to create reports using tables, crosstabs, charts, and other data regions with flexible layouts. § Section-based Reports follow the tradition of previous ActiveReports versions as well as being similar to Access reports. Using code-behind or scripts, you can respond to the various events that occur while the report generates to create extremely customized reports that are hard to produce with other products. § Fast .NET Reporting Engine ActiveReports 7 is optimized for speed. Its unique architecture allows the lean reporting engine to quickly read records from the data source and immediately render them to the output device. The simplicity of the design allows the data to pass through quickly from processing to rendering. § Flexible .NET API The extensive ActiveReports 7 API allows Visual Basic and C# developers to completely control the report processing engine to fit their needs. Events and properties control: § Data retrieval § Data transformation § Layout § Rendering In addition, the API gives the developer complete control over the rendered document to allow selective printing or export, post-render drawing or stamping on pages, n-page, and booklet printing. For added control, ActiveReports 7 provides unmanaged access to the print job, allowing tray selection and duplex printer management as the document is rendered to the printer. § Data Visualization and Layout Whether you need a simple listing or groups with keep-together control, master-detail reports, sub-reports, horizontal and vertical multi-column reports, address labels and badges, or richly formatted letters with mail merge support, ActiveReports is the solution. Simple and lightweight report controls allow you to easily create dazzling reports. With a selection including textbox, checkbox, line, shape, cross-section box, image, formatted text with mail merge, barcode (2D and 3D), chart, and other data visualization controls, they support a wide range of business reports. You can create reports of any size with nearly endless layout options. § Rich Data Binding .NET data sources allow you to connect to any of the standard databases, plus .NET in-memory objects and collections. In addition, unbound data mode opens up the report to data from anywhere, in any form. If your application can access it, so can the report engine. § Visual Studio Integrated Design Time The ActiveReports 7 report designer integrates with the Microsoft Visual Studio IDE allowing C# and Visual Basic developers to create reports and compile them into their Windows Forms, ASP.NET, and Silverlight applications. ActiveReports Professional Edition users can also use the royalty-free end-user report designer control to give similar report design functionality to end users within the business application. § Cross-platform Support ActiveReports 7 offers versatile viewers to extend the reach of your reports to every platform. Built-in report viewers include Windows Forms, Adobe Flash, Microsoft Silverlight, and a rich HTML viewer, all with built-in search functions, hyperlink interaction, a table of contents, and multi-page zoom view support. ActiveReports includes Adobe PDF export with advanced encryption and international font support, Microsoft Excel export, and Rich Text Format (RTF) export. The extensive API allows fine control over the exported documents and their properties. The ActiveReports reporting engine supports cloud computing on Microsoft's Windows Azure platform under partial trust as well as full trust. § Support for Migration from Other Reporting Tools ActiveReports 7 helps you preserve your past investments with easy report conversion from Microsoft Access and SAP Crystal Reports, thus greatly reducing the effort involved in recreating old reports when you migrate. No need to start from scratch! § Global Options and Localization Support Localize the ActiveReports user interface to meet the needs of all of your international users. (There are fully localized Chinese and Japanese versions for those specific markets.) Localization also extends to the reports themselves: the reporting engine can use locale-specific text and formatting without creating multiple reports. § Deployment ActiveReports 7 uses XCOPY deployment, making installation of your applications incredibly simple. There are no special merge modules to include, no licensing servers to install alongside your application, and no onerous activation procedures to go through.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值