Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Winforms Customeformat在我的datetimepicker上不起作用_Winforms_Date_Datetime_C# 4.0_Datetimepicker - Fatal编程技术网

Winforms Customeformat在我的datetimepicker上不起作用

Winforms Customeformat在我的datetimepicker上不起作用,winforms,date,datetime,c#-4.0,datetimepicker,Winforms,Date,Datetime,C# 4.0,Datetimepicker,我面临一个问题。windows窗体上的日期时间选择器,我将格式属性设置为Custom,将CustomFormat设置为dd/MM/yyyy,但当我运行应用程序时,日期时间选择器显示日历MM/dd/yyyy。我希望在我的应用程序中使用一致的格式,即dd/MM/yyyy。下面是更好理解的图片 运行时datetimepicker显示如屏幕下方所示 在设计器中生成的代码 this.engageDateDateTimePicker.CustomFormat = "dd/MM/yyyy";

我面临一个问题。windows窗体上的日期时间选择器,我将格式属性设置为Custom,将CustomFormat设置为
dd/MM/yyyy
,但当我运行应用程序时,日期时间选择器显示日历
MM/dd/yyyy
。我希望在我的应用程序中使用一致的格式,即
dd/MM/yyyy
。下面是更好理解的图片

运行时datetimepicker显示如屏幕下方所示

在设计器中生成的代码

 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);

您能告诉我如何解决此问题吗?我怀疑您没有在选择器上正确设置属性。从
DateTimePicker.CustomFormat
的文档中:

Format
属性必须设置为
DateTimePickerFormat.Custom
,此属性才能影响显示日期和时间的格式


我怀疑您没有在选择器上正确设置属性。从
DateTimePicker.CustomFormat
的文档中:

Format
属性必须设置为
DateTimePickerFormat.Custom
,此属性才能影响显示日期和时间的格式


我已经设置了可以在我设置属性的第一个图像中查看的属性。是我需要按代码设置属性。@A.Goutam:不,在您显示的第一幅图像中设置
CustomFormat
属性。您根本没有显示
格式
属性。你需要两个都设置。我只需要替换第一张图片。请你看一下,把你的护照给我好吗advice@A.Goutam:好的,看起来好多了。我现在很惊讶。如果您可以组合一个简短但完整的示例(只需在代码中手动创建一个表单-不涉及任何设计器),那么复制就更容易了。我的代码用于设置格式,如“EngageDateTimePicker.format=DateTimePickPerformat.Custom;”<代码>this.engagedatetimepicker.CustomFormat=“dd/MM/yyyy”我已经设置了可以在我设置属性的第一个图像中查看的属性。是我需要按代码设置属性。@A.Goutam:不,在您显示的第一幅图像中设置
CustomFormat
属性。您根本没有显示
格式
属性。你需要两个都设置。我只需要替换第一张图片。请你看一下,把你的护照给我好吗advice@A.Goutam:好的,看起来好多了。我现在很惊讶。如果您可以组合一个简短但完整的示例(只需在代码中手动创建一个表单-不涉及任何设计器),那么复制就更容易了。我的代码用于设置格式,如“EngageDateTimePicker.format=DateTimePickPerformat.Custom;”<代码>this.engagedatetimepicker.CustomFormat=“dd/MM/yyyy”