没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|使用教程|编辑:龚雪|2020-03-12 09:09:36.963|阅读 712 次
概述:DevExpress WinForms安装附带两个允许最终用户构建过滤器查询的控件:提供GUI的Filter控件和将Filter控件与基于文本输入的面板组合在一起的Filter Editor控件。
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
相关链接:
下载DevExpress v19.2完整版 DevExpress v19.2汉化资源获取
DevExpress Winforms Controls 内置140多个UI控件和库,完美构建流畅、美观且易于使用的应用程序。想要体验?点击下载>>
DevExpress WinForms安装附带两个允许最终用户构建过滤器查询的控件:提供GUI的Filter控件和将Filter控件与基于文本输入的面板组合在一起的Filter Editor控件。WinForms中,大多数数据感知控件都使用这些组件,但是您也可以将其包含在自己的表单中,并根据需要将其绑定到数据感知控件中。
为了说明这一点,下面是带有Filter Editor的数据网格,用户可以单击过滤器面板中的Edit Filter按钮来调出Filter Editor,并且由于属性DefaultFilterEditorView设置为TextAndVisual,因此可以看到Filter Editor Control的文本面板。
在下图中,您可以看到两个控件中可用的一些标准功能,包括“小于或等于”,“大于或等于”,“今天”,“昨天”以及许多其他功能。Filter控件和Filter Editor控件均提供多种功能供您选择,可用功能集因要为其构建表达式的数据字段的类型而异。
在某些情况下,标准函数集还不够。技术团队在处理大量技术支持问题发现,查找是最常见需要的自定义函数。以下是三种最受欢迎的方案:
从v19.1开始,Filter Editor控件和Filter控件完全支持自定义函数,从而可以轻松实现上述方案和许多其他方案。
技术基础
自定义函数是实现接口ICustomFunctionDisplayAttributes的类,请注意如果需要服务器端对自定义函数的处理,则可以额外实现ICustomFunctionOperatorFormattable接口,但是在本文范围内,我们仅关注ICustomFunctionDisplayAttributes。
这些是接口实现所需的方法和属性:
最后,我们建议添加两个静态便利函数Register和Unregister。 这是一个可选步骤,但是实现很简单(请参见下文),并且它们以CriteriaOperator类型调用现有的帮助器。
示例
供您参考,下面是三个示例,它们涵盖了上面提到的三个最需要的方案。 第一个自定义函数称为NotBeginsWith,它是对标准函数BeginsWith的取反。
public class NotBeginsWithFunction : ICustomFunctionDisplayAttributes { public const string FunctionName = "NotBeginsWith"; static readonly NotBeginsWithFunction instance = new NotBeginsWithFunction(); public static void Register() { CriteriaOperator.RegisterCustomFunction(instance); } public static bool Unregister() { return CriteriaOperator.UnregisterCustomFunction(instance); } public string Name => FunctionName; public string DisplayName => "Does not begin with"; public object Image => "FontSizeDecrease;Office2013"; public string Description => "Hides records when the field begins with the given value"; public FunctionCategory Category => FunctionCategory.Text; public int MinOperandCount => 2; public int MaxOperandCount => 2; public bool IsValidOperandCount(int count) => count == 2; public bool IsValidOperandType(int operandIndex, int operandCount, Type type) => type == typeof(string); public Type ResultType(params Type[] operands) => typeof(bool); public object Evaluate(params object[] operands) { if(operands[0] != null && operands[1] != null) { string str1 = operands[0].ToString(); string str2 = operands[1].ToString(); return !str1.StartsWith(str2, StringComparison.InvariantCultureIgnoreCase); } return false; } }
这是第二个自定义函数InternalDaysOfToday,用于检查DateTime值是否在今天-N天和今天+ N天的时间范围内。
public class WithinDaysOfTodayFunction : ICustomFunctionDisplayAttributes { public const string FunctionName = "WithinDaysOfToday"; static readonly WithinDaysOfTodayFunction instance = new WithinDaysOfTodayFunction(); public static void Register() { CriteriaOperator.RegisterCustomFunction(instance); } public static bool Unregister() { return CriteriaOperator.UnregisterCustomFunction(instance); } public string Name => FunctionName; public string DisplayName => "Within days of today"; public object Image => "SwitchTimeScalesTo;Size16x16;Colored"; public string Description => "Shows records when the field value within X days of today"; public FunctionCategory Category => FunctionCategory.DateTime; public int MinOperandCount => 2; public int MaxOperandCount => 2; public bool IsValidOperandCount(int count) => count == 2; public bool IsValidOperandType(int operandIndex, int operandCount, Type type) => operandIndex == 0 && type == typeof(DateTime) || operandIndex == 1 && type == typeof(int); public Type ResultType(params Type[] operands) => return typeof(bool); public object Evaluate(params object[] operands) { DateTime dt = Convert.ToDateTime(operands[0]); int days = Convert.ToInt32(operands[1]); DateTime start = DateTime.Today.AddDays(-days); DateTime end = DateTime.Today.AddDays(days); return dt >= start && dt <= end; } }
最后,IsWeekend测试DateTime值是星期六还是星期天。
public class IsWeekendFunction : ICustomFunctionDisplayAttributes { public const string FunctionName = "IsWeekend"; static readonly IsWeekendFunction instance = new IsWeekendFunction(); public static void Register() { CriteriaOperator.RegisterCustomFunction(instance); } public static bool Unregister() { return CriteriaOperator.UnregisterCustomFunction(instance); } public string Name => FunctionName; public string DisplayName => "Is weekend"; public object Image => "DayView;Office2013"; public string Description => "Shows records when the field value is on Saturday or Sunday"; public FunctionCategory Category => FunctionCategory.DateTime; public int MinOperandCount => 1; public int MaxOperandCount => 1; public bool IsValidOperandCount(int count) => count == 1; public bool IsValidOperandType(int operandIndex, int operandCount, Type type) => type == typeof(DateTime); public Type ResultType(params Type[] operands) => typeof(bool); public object Evaluate(params object[] operands) { DateTime dt = Convert.ToDateTime(operands[0]); return dt.DayOfWeek == DayOfWeek.Sunday || dt.DayOfWeek == DayOfWeek.Saturday; } }
DevExpress v19.2线上公开课即将开课,前10名免费参与哦~
DevExpress技术交流群:540330292 欢迎一起进群讨论
扫描关注DevExpress中文网微信公众号,及时获取最新动态及最新资讯
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@evget.com
文章转载自:慧都网从 2025.2 版本开始,用于仪表板创建的 Stimulsoft 产品引入了InclusionMode属性,我们将在本文中对其进行探讨。
本文将为大家介绍如何在Telerik UI for WinForms应用中使用Kendo UI for Angular组件来交换通信和事件,欢迎下载新版组件体验!
本教程提供DevExpress WinFormsWinExplorer视图的基本信息,欢迎下载最新版组件体验!
在许多企业应用程序中,从 Visio 文件读取形状数据是一项常见需求,因为这些应用程序中的图表都包含有意义的元数据。本教程将借助Aspose.Diagram,以清晰实用的方式指导您使用 C# 读取形状数据。
为Windows Forms平台创建具有影响力的业务解决方案,高性价比WinForms界面控件套包。
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@evget.com
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢
慧都科技 版权所有 Copyright 2003-
2025 渝ICP备12000582号-13 渝公网安备
50010702500608号