How to: Register an Additional Type of XtraReport Parameter 如何:注册其他类型的 XtraReport 参数
This example demonstrates how to extend the list of parameter types available in the Report Designer.
此示例演示如何扩展报表设计器中可用的参数类型列表。
In this topic, it is assumed that you have an XAF application that uses the Reports V2 Module, and you have created one or more reports (see Reports V2 Module Overview).
在本主题中,假定您有一个使用报表 V2 模块的 XAF 应用程序,并且您创建了一个或多个报表(请参阅报表 V2 模块概述)。
Access an XtraReportDataTypeProvider instance using the XafReportDataTypeProvider parameter passed to the static ReportDesignExtensionManager.CustomizeReportExtension event. Then, handle the XtraReportDataTypeProvider.CustomAddParameterTypes event and add custom types to the Dictionary list passed to the event handler. Additionally, handle the XtraReportDataTypeProvider.GetCustomEditableDataTypes event and add custom types to the Types array passed to the event handler. The following snippet illustrates how to add the Gender enumeration type.
使用传递给静态报表设计扩展管理器的 XafReportDataTypeProvider 参数访问 XtraReportDataTypeProvider 实例。然后,处理 XtraReportDataTypeProvider.自定义添加参数类型事件,并将自定义类型添加到传递给事件处理程序的字典列表中。此外,处理 XtraReportDataTypeProvider.获取自定义可编辑数据类型事件,并将自定义类型添加到传递给事件处理程序的"类型"数组中。以下代码段说明了如何添加性别枚举类型。
using DevExpress.ExpressApp.ReportsV2; // ... static class Program { static void Main() { ReportDesignExtensionManager.CustomizeReportExtension += ReportDesignExtensionManager_CustomizeReportExtension; // ... } static void ReportDesignExtensionManager_CustomizeReportExtension(object sender, CustomizeReportExtensionEventArgs e) { e.XafReportDataTypeProvider.CustomAddParameterTypes += XafReportDataTypeProvider_CustomAddParameterTypes; e.XafReportDataTypeProvider.GetCustomEditableDataTypes += XafReportDataTypeProvider_GetCustomEditableDataTypes; } static void XafReportDataTypeProvider_CustomAddParameterTypes(object sender, AddCustomParameterTypesEventArgs e) { e.Dictionary.Add(typeof(Gender), "Gender"); } static void XafReportDataTypeProvider_GetCustomEditableDataTypes(object sender, GetCustomEditableDataTypesEventArgs e) { List<Type> types = new List<Type>(e.Types); types.Add(typeof(Gender)); e.Types = types.ToArray(); } // ... } public enum Gender { Male, Female}
The result is demonstrated in the image below.
结果如下图所示。
XAF开发成品案例参考
如果您觉得阅读本文对您有帮助,请点一下“推荐”按钮,您的“推荐”将是我最大的写作动力!欢迎各位转载,但是未经作者本人同意,转载文章之后必须在文章页面明显位置给出作者和原文连接,否则保留追究法律责任的权利。
作者博客: http://www.cnblogs.com/foreachlife
欢迎加入CIIP框架\XAF技术应用交流群: 336090194 群文件中有更多相关工具及文档资料
转载请注明出处。多谢!
欢迎加我微信: admiralcn 或扫码:

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!