前言

上一篇博文《玩转控件:重绘ComboBox —— 让ComboBox多列显示》中,根据大家的回馈,ComboBox已经支持筛选了,更新见博文最后最后最后面.

  奇葩

这两天遇到一个很“诡异”的情况,之前手机拦截短信一直用腾讯手机管家,这两天发神经,把腾讯手机管家卸载掉,换成360手机管家。然后一如既往的设置好闹钟,睡觉.. 结果尼玛一觉睡到自然醒!拿过手机一看11:35am,手机闹钟居然没响!我很希望今天是星期六,为此我还狠劲的捏了下我白里透红的小脸,却无法扭转今天星期五的窘境。 这还不是最奇葩的,奇葩的是,我拿起手机惊奇的发现:360不见了...腾讯也不见了...闹钟也不响了...我凌乱了. 不知道有没有人遇到过类似的问题、

  缘由

这两天在维护DevExpress控件开发的报表,测试人员提出报表查询条件需要按月查询,我木讷的对着Dev自带的DateEdit控件许久,又找了几个Dev其他的时间控件,没有一个可以达到需求标准,于是有了下文:本篇博文代码部分来自网络,地址:http://www.devexpress.com/Support/Center/Question/Details/CQ60337

  故技重施:新建组件

根据最近看了3遍的《新三国演义》中,诸葛亮占荆州后收取零陵时,一屠夫的话:"说出吾名,吓汝一跳"。随将该组件类前缀用鄙人姓名字母的缩写,使其继承DevExpress的DateEdit控件类,如下:

  public partial class KzxDateEdit : DateEdit

我用的DevExpress控件是v10.1的,经过测试DevExpress神似在v7.1以上才支持Vista模式.(此处未经考证,如官方人员发现,请将此言论归为 大言不惭 之类别!)

下面贴出核心代码:

 public partial class KzxDateEdit : DateEdit
{
public KzxDateEdit()
{
InitializeComponent();
Properties.VistaDisplayMode = DevExpress.Utils.DefaultBoolean.True;
Properties.DisplayFormat.FormatString = "yyyy-MM";
Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
Properties.Mask.EditMask = "yyyy-MM";
Properties.ShowToday = false;
} public KzxDateEdit(IContainer container)
{
container.Add(this); InitializeComponent();
}
protected override PopupBaseForm CreatePopupForm()
{
if (Properties.VistaDisplayMode == DevExpress.Utils.DefaultBoolean.True)
return new CustomVistaPopupDateEditForm(this);
return new PopupDateEditForm(this);
} }
public class CustomVistaPopupDateEditForm : VistaPopupDateEditForm
{
public CustomVistaPopupDateEditForm(DateEdit ownerEdit) : base(ownerEdit) { }
protected override DateEditCalendar CreateCalendar()
{
return new CustomVistaDateEditCalendar(OwnerEdit.Properties, OwnerEdit.EditValue);
}
}
public class CustomVistaDateEditCalendar : VistaDateEditCalendar
{
public CustomVistaDateEditCalendar(RepositoryItemDateEdit item, object editDate) : base(item, editDate) { } protected override void Init()
{
base.Init();
this.View = DateEditCalendarViewType.YearInfo;
} protected override void OnItemClick(DevExpress.XtraEditors.Calendar.CalendarHitInfo hitInfo)
{
DayNumberCellInfo cell = hitInfo.HitObject as DayNumberCellInfo;
if (View == DateEditCalendarViewType.YearInfo)
{
DateTime dt = new DateTime(DateTime.Year, cell.Date.Month, , , , ); DateTime tempDate = dt.AddMonths().AddDays(-);
tempDate = new DateTime(tempDate.Year, tempDate.Month, tempDate.Day, , , );
OnDateTimeCommit(tempDate, false);
}
else
base.OnItemClick(hitInfo);
}
}
   回到窗体,重新定义窗体设计器的代码InitializeComponent()

没错,仍然需要使出拖控件大法,将DevExpress中DateEdit控件拖到窗体中,然后将窗体的设计代码中InitializeComponent()方法剪切到窗体的.cs文件中,然后重新制定该DateEdit控件实例化对象即可。

 //this.dateEdit1 = new DevExpress.XtraEditors.DateEdit();
this.dateEdit1 = new KzxDateEdit();

下面是运行效果图:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAARsAAAEQCAIAAAAPiEe1AAASG0lEQVR4nO2deXhU5b2Av7+uXq1KXVC53lt7L6XgUq2WumAVqx2t1rW2LlUrCi6sAhEEQRBFIJCENew7g2EXoSwqMiIiSnsFRapFvKCyZBIIJISAJJz7x4RkMuc728zvZE4m7/u8j09ycs75Pg/nzTczkIw6rXnH5Dz9Z51Ob9HpRy06n/Hzzme27HJmq65ntera5JJuTS7t9uPLnj/7su7nXN79nF/0OPeKnudd0fO8K7Oa/jLr/KteOP+qXhdc3evCX/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YVLrmKTJEPUze5mzap0bap0ki88zAotxcXJs905KT/bhpnGfqo9TP5IMzzwwsCiCNUBSAJBQFIAlFAUhCUQCSUBSAJBQFIAlFAUhCUQCSUBSAJBQFIAlFAUhCUQCSUBSAJBQFIAlFAUhCUQCSUBSAJBQFIAlFAUhCUQCSUBSAJBQFIAlFAUhCUQCSUBSAJBTVWEjXb59ubFBUxpLwy/Ipqn6gqMwkIG/h0wihqAzE8c1+tG/0Yn7XEiJMAorKQGyKcvludAm9gXsoKgMRKcq32WU4FJWB2BelfYc/XsaQgqIyEPdrlHl/ikoRispMXD6cM2+kqBShqIzF6oGc/Wt9FJUiFAUgCUUBSEJRAJJQFIAkFAUgCUUBSEJRAJI0gKIQG5aBLgqxIRrQohDRpRSFKClFIUpKUYiSUhSipBSFKClFIUpKUYiSUhSipBSFKClFIUpKUYiSUhSipBSFKClFIUpKUYiSUhSipBSFKClFIUr6/9WVCvR8nqkfAAAAAElFTkSuQmCC" alt="" />

   源码下载链接

源码下载

玩转控件:重绘DEVEXPRESS中DateEdit控件 —— 让DateEdit支持只选择年月 (提供源码下载)的更多相关文章

  1. VC++中关于控件重绘函数/消息 OnPaint,OnDraw,OnDrawItem,DrawItem的区别

    而OnPaint()是CWnd的类成员,同时负责响应WM_PAINT消息. OnDraw()是CVIEW的成员函数,并且没有响应消息的功能.这就是为什么你用VC成的程序代码时,在视图类只有OnDraw ...

  2. 深入Windows窗体原理及控件重绘技巧

    之前有学MFC的同学告诉我觉得Windows的控件重绘难以理解,就算重绘成功了还是有些地方不明白,我觉得可能很多人都有这样的问题,在这里我从Windows窗体的最基本原理来讲解,如果你有类似的疑惑希望 ...

  3. ActiveX 控件重绘无效问题,用CClientDC 而不是CPaintDC

    ActiveX 控件重绘子控件时,用Invalid()会出现无效的情况即不会更新界面. OnPaint 方法里,是用的 CPaintDC,经测试无效,后换CClientDC,发现可以,百度查他们的区别 ...

  4. Winforn中DevExpress的TreeList中显示某路径下的所有目录和文件(附源码下载)

    场景 Winform中DevExpress的TreeList的入门使用教程(附源码下载): https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/deta ...

  5. Winform中DevExpress的TreeList的入门使用教程(附源码下载)

    场景 Winform控件-DevExpress18下载安装注册以及在VS中使用: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/1 ...

  6. openlayers4 入门开发系列之地图导航控件篇(附源码下载)

    前言 openlayers4 官网的 api 文档介绍地址 openlayers4 api,里面详细的介绍 openlayers4 各个类的介绍,还有就是在线例子:openlayers4 官网在线例子 ...

  7. arcgis api 3.x for js 共享干货系列之二自定义 Navigation 控件样式风格(附源码下载)

    0.内容概览 自定义 Navigation 控件样式风格 源码下载 1.内容讲解 arcgis api 3.x for js 默认的Navigation控件样式风格如下图:这样的风格不能说不好,各有各 ...

  8. leaflet-webpack 入门开发系列四图层控件样式优化篇(附源码下载)

    前言 leaflet-webpack 入门开发系列环境知识点了解: node 安装包下载webpack 打包管理工具需要依赖 node 环境,所以 node 安装包必须安装,上面链接是官网下载地址 w ...

  9. 基于DevExpress的SpreadsheetControl实现对Excel的打开、预览、保存、另存为、打印(附源码下载)

    场景 Winform控件-DevExpress18下载安装注册以及在VS中使用: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/1 ...

随机推荐

  1. 20165310 Java实验五《网络编程与安全》

    20165310 Java实验五<网络编程与安全> 任务一 题目:①编写MyBC.java实现中缀表达式转后缀表达式的功能:②编写MyDC.java实现从上面功能中获取的表达式中实现后缀表 ...

  2. 串口WIF简单I调试

    串口WIF简单I调试 /*********************************************************************** Title:Wifi串口调试 H ...

  3. CocoaPods的安装及使用

    CocoaPods安装使用及配置私有库 http://www.exiatian.com/cocoapods%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8%E5%8F%8A%E ...

  4. xshell的Solarized Dark配色方案

    之前在ubuntu, kali, mint, air下都使用这一款配色方案,后来在网上看到有人在xshell中使用,配色方案有分享,就是一起无法导入 原来这个东西在你现有的连接无法直接导入,需要重新打 ...

  5. linux下使用docker-thunder-xware进行离线下载

    1.环境: lsb_release -a hello@jhello:~$ lsb_release -aNo LSB modules are available.Distributor ID: Ubun ...

  6. LightOJ 1296 Again Stone Game(sg函数)题解

    题意:每次必须拿且只能拿不超过一半的石头,不能拿为败 思路:显然算出每个的sg函数,但是范围1e9显然不能直接打表.所以先打表找规律,发现偶数一直是自己的一半,奇数好像没规律.偶数x的sg函数值是x/ ...

  7. 安卓开发 Activity入门

    生命周期 Activity包含5种状态,涉及7种方法 1. 启动状态 2. 运行状态 *** 即使内存不足,Android先销毁栈底的Activity,来确保当前Activity正常运行 3. 暂停状 ...

  8. 【深度学习】Pytorch 学习笔记

    目录 Pytorch Leture 05: Linear Rregression in the Pytorch Way Logistic Regression 逻辑回归 - 二分类 Lecture07 ...

  9. Spirng boot 启动的时候进行监控检查不通过停止服务与自定义健康监控节点

    基于 spring-boot-starter-actuator   • 前提条件: <dependency>   <groupId>org.springframework.bo ...

  10. UVa 208 消防车(dfs+剪枝)

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...