如何让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[]{"日"春枝,
"一",
"二",
"三",
"四",
"五",