Reputation: 107
I want to get datetime from user in windows form C#.net .I use datetimepicker of .net control but it is gregorian so how can I change This datetimepicker to shamsi date???
Upvotes: 7
Views: 11153
Reputation: 115
No need for an additional library. You can change the calander type in Region Setting on the control panel.
And add these lines after InitializeComponent();
Application.CurrentCulture = new CultureInfo("fa-IR");
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = Application.CurrentCulture.DateTimeFormat.ShortDatePattern;
Upvotes: -1
Reputation: 31
Previously I tried Behrooz Moghaddam's code but using the default winforms DateTimePicker control, but that code didn't work.
Now I am using the telerik RadDateTimePicker
and write this code after InitializeComponent()
and instead of "fa-IR"
use your culture.
Application.CurrentCulture = new CultureInfo("fa-IR");
radDateTimePicker1.Format = DateTimePickerFormat.Custom;
radDateTimePicker1.CustomFormat = Application.CurrentCulture.DateTimeFormat.ShortDatePattern;
Upvotes: 1