-1

What's the easiest way to override the default value that's shown by DateTimePicker.

I mean it shows 7/31/2018 by default, but I'd like it to show DD/MM/YYYY by default, to let users know what is the required pattern to DateTime.

Not format, I talking about exactly the shown value.

So to show 'D', 'D', '/', 'M', 'M', '/', 'Y', 'Y', 'Y', 'Y' characters.

My best idea is to make my own DateTimePicker by UserControl.

Is there any better solution to my problem?

So the DateTimePicker looks like this now:

enter image description here

But I'd like it to show this by default:

enter image description here

koviroli
  • 1,422
  • 1
  • 15
  • 27
  • The format shown by default is the computer's regional format. If you are shown `MM/dd/yyyy`, your computer is most likely in that format as well – Camilo Terevinto Jul 31 '18 at 12:04
  • I'm no talking about the format. I talking about the exact shown value. – koviroli Jul 31 '18 at 12:05
  • That's exactly what the format is, the text displayed on the control. The value is a `DateTime` instance which doesn't have a format. – Camilo Terevinto Jul 31 '18 at 12:07
  • Have you tried setting `MyPicker.Value' ? – Neil Jul 31 '18 at 12:07
  • Updated with pictures. – koviroli Jul 31 '18 at 12:13
  • There is still a format problem. The first image shows mm/dd/yyyy, but you want the user to input dd/mm/yyyy. Which is it? – Neil Jul 31 '18 at 12:26
  • Omg. Are you joking now or really don't understand the issue? – koviroli Jul 31 '18 at 12:29
  • if question about place holder, change your question. And add that you want placeholder. If you want custom datetime format see https://stackoverflow.com/questions/19466805/set-default-format-of-datetimepicker-as-dd-mm-yyyy – KreminT Jul 31 '18 at 12:42
  • Placeholder, I'd like to write placeholder, just foget the word. But I stated with bold, that I'm not talking about format. Ty anyway. – koviroli Jul 31 '18 at 12:45
  • 1
    If you want placeholder for winforsm you may write custom controler such https://social.msdn.microsoft.com/Forums/windows/en-US/ee0c5fbe-8d18-4899-8df2-46535b570bb4/how-to-create-a-nullable-and-editable-datetimepicker?forum=winforms – KreminT Jul 31 '18 at 12:48
  • @KreminT thanks, the msdn forum link solved my problem! If you post it as answer, I accept it. – koviroli Aug 01 '18 at 08:38
  • @koviroli i posted answer – KreminT Aug 01 '18 at 08:40

2 Answers2

1

As i understand you need placeholder with text "DD/MM/YYYY",But Placeholders are not supported in windows predefined controls, you have to create custom control if you need placeholder in winforms.

Create custom control for calendar and customize it as per your requirement.

Hiren Patel
  • 1,071
  • 11
  • 34
-1

At the start of your program, set the culture to be UK (or whatever you require):

void Main()
{
   CultureInfo.Current = new CultureInfo("en-GB");

}

You may also need to set the culture of the current thread. This page gives more information.

Neil
  • 11,059
  • 3
  • 31
  • 56