DevExpress 的控件至关好看并且很好用,但 DateEdit 在是显示周名时,只能显示一个“星”字。html
如下是解决方法,此解决方法不需修改其源码,因此免去了从新编译的必要,可直接使用其发布的标准DLL。 ide
public class MyDateEdit : DevExpress.XtraEditors.DateEdit
{
protected override DevExpress.XtraEditors.Popup.PopupBaseForm CreatePopupForm()
{
return new MyPopupDateEditForm(this);
}
}post
public class MyPopupDateEditForm : DevExpress.XtraEditors.Popup.PopupDateEditForm
{
public MyPopupDateEditForm(MyDateEdit dateEdit) : base(dateEdit)
{
}this
protected override DevExpress.XtraEditors.Controls.DateEditCalendar CreateCalendar()
{
return new MyDateEditCalendar(OwnerEdit.Properties, OwnerEdit.EditValue);
}orm
}htm
public class MyDateEditCalendar : DevExpress.XtraEditors.Controls.DateEditCalendar
{
public MyDateEditCalendar(
DevExpress.XtraEditors.Repository.RepositoryItemDateEdit item,
object editDate) : base (item, editDate)
{
}blog
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[]{
"日",
"一",
"二",
"三",
"四",
"五",
"六"};string
info.DateFormat = newFormat;it
return info;
}
}
使用时,只需 MyDateEdit dateEdit1 = new MyDateEdit() 就能够了。