zoukankan      html  css  js  c++  java
  • DevExpress的DateEdit控件正确显示日期的周名称

    DevExpress 的控件相当好看而且很好用,但 DateEdit 在是显示周名时,只能显示一个“星”字。

    以下是解决方法,此解决方法不需修改其源码,所以免去了重新编译的必要,可直接使用其发布的标准DLL。  

      public class MyDateEdit : DevExpress.XtraEditors.DateEdit
      {
       protected override DevExpress.XtraEditors.Popup.PopupBaseForm CreatePopupForm()
       {
        return new MyPopupDateEditForm(this);
       }
      }

      public class MyPopupDateEditForm : DevExpress.XtraEditors.Popup.PopupDateEditForm
      {
       public MyPopupDateEditForm(MyDateEdit dateEdit) : base(dateEdit)
       {
       }

       protected override DevExpress.XtraEditors.Controls.DateEditCalendar CreateCalendar()
       {
        return new MyDateEditCalendar(OwnerEdit.Properties, OwnerEdit.EditValue);
       }

      }

      public class MyDateEditCalendar : DevExpress.XtraEditors.Controls.DateEditCalendar
      {
       public MyDateEditCalendar(
        DevExpress.XtraEditors.Repository.RepositoryItemDateEdit item,
        object editDate) : base (item, editDate)
       {
       }

       protected override DevExpress.XtraEditors.ViewInfo.DateEditInfoArgs CreateInfoArgs()
       {
        DevExpress.XtraEditors.ViewInfo.DateEditInfoArgs info = base.CreateInfoArgs ();
        System.Globalization.DateTimeFormatInfo newFormat =
         (System.Globalization.DateTimeFormatInfo)info.DateFormat.Clone();

        // 以下是重新设置日期的周名称。
        // 缺省情况下,前面带有“星期”两字,也正是因为如此才导致所谓的错误。
        // 注意,当前实现未处理语言环境,仅适用于中文环境。 
        newFormat.AbbreviatedDayNames = new string[]{
                    "日",
                    "一",
                    "二",
                    "三",
                    "四",
                    "五",
                    "六"};

        info.DateFormat = newFormat;

        return info;
       }

      }

    使用时,只需 MyDateEdit dateEdit1 = new MyDateEdit() 就可以了。

    出处:https://www.cnblogs.com/MaxWoods/archive/2011/10/11/2207525.html

  • 相关阅读:
    Swift学习笔记(7)--控制流
    安装APK时报 Installation failed with message Failed to finalize session : INSTALL_FAILED_USER_RESTRICTED: Invalid apk.
    Android Notification 的四种使用方式
    Socket.io
    socket
    socket.io 中文手册 socket.io 中文文档
    Android中的CardView使用
    TabLayout实现底部导航栏(2)
    使用PagerSlidingTabStrip实现顶部导航栏
    TabLayout实现顶部导航栏(1)
  • 原文地址:https://www.cnblogs.com/mq0036/p/10399769.html
Copyright © 2011-2022 走看看