Customeformat 不适用于我的日期时间选择器
Customeformat is not working on my datetimepicker
我遇到了一个问题。我的 windows 表单上有一个 datetimepicker,我将格式属性设置为 Custom,将 CustomeFormat 设置为 dd/MM/yyyy
,但是当我 运行 应用程序时,datetimepicker 显示日历 MM/dd/yyyy
。我希望在我的应用程序中使用一致的格式 dd/MM/yyyy
。为了更好地理解,下面是图片。
和运行时日期时间选择器显示如下屏幕
在设计器中生成的代码
this.engageDateDateTimePicker.CustomFormat = "dd/MM/yyyy";
this.engageDateDateTimePicker.DataBindings.Add(new System.Windows.Forms.Binding("Value", this.prol01BindingSource, "EngageDate", true, System.Windows.Forms.DataSourceUpdateMode.OnValidation, null, "d"));
this.engageDateDateTimePicker.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.engageDateDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.engageDateDateTimePicker.Location = new System.Drawing.Point(885, 96);
this.engageDateDateTimePicker.Name = "engageDateDateTimePicker";
this.engageDateDateTimePicker.Size = new System.Drawing.Size(136, 20);
this.engageDateDateTimePicker.TabIndex = 27;
this.engageDateDateTimePicker.ValueChanged += new System.EventHandler(this.engageDateDateTimePicker_ValueChanged);
你能告诉我如何解决这个问题吗
我怀疑您没有在选择器上适当地设置 Format
属性。来自 DateTimePicker.CustomFormat
的文档:
The Format
property must be set to DateTimePickerFormat.Custom
for this property to affect the formatting of the displayed date and time.
我遇到了一个问题。我的 windows 表单上有一个 datetimepicker,我将格式属性设置为 Custom,将 CustomeFormat 设置为 dd/MM/yyyy
,但是当我 运行 应用程序时,datetimepicker 显示日历 MM/dd/yyyy
。我希望在我的应用程序中使用一致的格式 dd/MM/yyyy
。为了更好地理解,下面是图片。
和运行时日期时间选择器显示如下屏幕
在设计器中生成的代码
this.engageDateDateTimePicker.CustomFormat = "dd/MM/yyyy";
this.engageDateDateTimePicker.DataBindings.Add(new System.Windows.Forms.Binding("Value", this.prol01BindingSource, "EngageDate", true, System.Windows.Forms.DataSourceUpdateMode.OnValidation, null, "d"));
this.engageDateDateTimePicker.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.engageDateDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.engageDateDateTimePicker.Location = new System.Drawing.Point(885, 96);
this.engageDateDateTimePicker.Name = "engageDateDateTimePicker";
this.engageDateDateTimePicker.Size = new System.Drawing.Size(136, 20);
this.engageDateDateTimePicker.TabIndex = 27;
this.engageDateDateTimePicker.ValueChanged += new System.EventHandler(this.engageDateDateTimePicker_ValueChanged);
你能告诉我如何解决这个问题吗
我怀疑您没有在选择器上适当地设置 Format
属性。来自 DateTimePicker.CustomFormat
的文档:
The
Format
property must be set toDateTimePickerFormat.Custom
for this property to affect the formatting of the displayed date and time.