提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|使用教程|编辑:龚雪|2020-03-12 09:09:36.963|阅读 753 次
概述:DevExpress WinForms安装附带两个允许最终用户构建过滤器查询的控件:提供GUI的Filter控件和将Filter控件与基于文本输入的面板组合在一起的Filter Editor控件。
#慧都22周年庆大促·界面/图表报表/文档/IDE/IOT/测试等千款热门软控件火热促销中>>
相关链接:
下载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@hmdbvip.cn
文章转载自:慧都网



Parasoft C/C++test是一款专为C/C++代码设计的自动化测试工具,通过静态代码分析、单元测试和运行时错误检测等功能,帮助开发团队在早期发现并修复缺陷,提升代码质量和开发效率 。在实际使用中,尤其是在VC6此类旧版开发环境中执行单元测试时,可能会因环境兼容性问题触发链接错误。
本文主要介绍如何在MVVM应用程序中使用虚拟源,欢迎下载最新版组件体验!
Aspose.Slides for Java使用户能够轻松地操作幻灯片、添加注释和转换文件。其易用性和集成能力提高了工作效率,使开发人员能够专注于更关键的任务。
在嵌入式软件测试领域,对交叉编译代码进行单元测试是一大挑战。Parasoft C/C++test作为专业的C/C++测试工具,能够与劳特巴赫Trace32调试器深度集成。下面会详细介绍如何在C++test中配置Trace32调试器,实现对PowerPC架构程序的单元测试,涵盖环境设置、项目导入到测试执行的全过程。
相关产品
为Windows Forms平台创建具有影响力的业务解决方案,高性价比WinForms界面控件套包。
最新文章 MORE
永利最大(官方)网站相关的文章 MORE
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@hmdbvip.cn
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢
永利最大(官方)网站