Date Format Changes from Regional Settings

N

Naeem

HI All,

I have a problem can anyone help?

We are using DateTimePicker control for date editing on many forms.
Now we have a special requirement that if a user will change the datetime
format from the regional settings then the new datetime format must not
update in the DateTimePicker control (which actually updates those changes
on runtime) untrill user will restart the application.

I tried to find any solution but failed. Can anyone help?

Thanks
Naeem
 
T

Truong Hong Thi

Hi Naeem,

You can set DateTimePicker.Format to Custom at initilization (e.g, in
FormLoad, or in constructor after InitializeComponents). For example:

picker.Format = DateTimePickerFormat.Custom;
picker.CustomFormat = DateTimeFormatInfo.CurrentInfo.LongDatePattern;

Thus at initialization, the picker's format will be set as defined in
Regional Settings. After you changed it, the picker is not affected
(cos it uses custom format). Next time you run the app, it is
initialized again and match what you set in regional settings.

Hope this helps,
Thi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top