1. 设置Mask.EditMask和DisplayFormat,EditFormat属性,设置为一致:'yyyy-MM-dd HH:mm'; //按照想要的显示格式设置此字符串。
this.dateEdit1.Properties.DisplayFormat.FormatString = "yyyy-MM-dd HH:mm"; this.dateEdit1.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime; this.dateEdit1.Properties.EditFormat.FormatString = "yyyy-MM-dd HH:mm"; this.dateEdit1.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.DateTime; this.dateEdit1.Properties.Mask.EditMask = "yyyy-MM-dd HH:mm";
2. 如果要显示时间需要设置Vistahttp://www.devze.comDisplayMode=true, VistaEditTime=true。意思为显示时间,在时间控件中会出现时钟图标,并可以编辑时间。
this.dateEdit1.Properties.VistaDisplayMode = DevExpress.Utils.DefaultBoolean.True; this.dateEdit1.Properties.VistaEditTime = DevExpress.Utils.DefaultBoolean.True;
3. 设置时间部分的格式,时间部分指的是打开日期空间后,在时钟图标下的显示的日期格式。
this.dateEdit1.Properties.V开发者_JAVAistaTimeProperties.DisplayFormat.FormatString = "HH:mm"; this.dateEdit1.Properties.VistaTimeProperties.DisplayFormat.FormatTyp编程客栈e = DevExpress.Utils.FormatType.DateTime; this.phpdateEdit1.Properties.VistaTimeProperties.EditFormat.FormatString = "HH:mm"; this.dateEdit1.Properties.VistaTimeProperties.EditFormat.FormatType = DevExpress.Utils.FormatType.DateTime; this.dateEdit1.Properties.VistaTimeProperties.Mask.EditMask = "HH:mm";
下图为设置后的日期控件
该日期控件的设置全代码
//编程客栈 // dateEdit1 // this.dateEdit1.EditValue = new System.DateTime(2015, 6, 26, 14, 29, 8, 441); this.dateEdit1.Location = new System.Drawing.Point(24, 154); this.dateEdit1.Name = "dateEdit1"; this.dateEdit1.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}); this.dateEdit1.Properties.DisplayFormat.FormatString = "yyyy-MM-dd HH:mm"; this.dateEdit1.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime; this.dateEdit1.Properties.EditFormat.FormatString = "yyyy-MM-dd HH:mm"; this.dateEdit1.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.DateTime; this.dateEdit1.Properties.Mask.EditMask = "yyyy-MM-dd HH:mm"; this.dateEdit1.Properties.VistaDisplayMode = DevExpress.Utils.DefaultBoolean.True; this.dateEdit1.Properties.VistaEditTime = DevExpress.Utils.DefaultBoolean.True; this.dateEdit1.Properties.VistaTimeProperties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton()}); this.dateEdit1.Properties.VistaTimeProperties.DisplayFormat.FormatString = "HH:mm"; this.dateEdit1.Properties.VistaTimeProperties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime; this.dateEdit1.Properties.VistaTimePro编程客栈perties.EditFormat.FormatString = "HH:mm"; this.dateEdit1.Properties.VistaTimeProperties.EditFormat.FormatType = DevExpress.Utils.FormatType.DateTime; this.dateEdit1.Properties.VistaTimeProperties.Mask.EditMask = "HH:mm"; this.dateEdit1.Size = new System.Drawing.Size(134, 21); this.dateEdit1.TabIndex = 5;
到此这篇关于DevExpress的DateEdit设置显示日期和时间的方法的文章就介绍到这了,更多相关DevExpress DateEdit显示日期时间内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!
精彩评论