i have facing a problem. A datetimepicker on my windows form and i set the format properties to Custom and CustomeFormat to dd/MM/yyyy
but when i run the application the datetimepicker display the calendar MM/dd/yyyy
. I want consistent format in my application that is dd/MM/yyyy
. Below is the picture for better understanding.
and Runtime datetimepicker displaying like below screen
Code that is generating in designer
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);
Can you tell me how can i resolve this
I suspect you haven't set the Format
property appropriately on the picker. From the docs for DateTimePicker.CustomFormat
:
The
Format
property must be set toDateTimePickerFormat.Custom
for this property to affect the formatting of the displayed date and time.
See more on this question at Stackoverflow