saba
saba

Reputation: 107

Persian datetimepicker in C# .net windows form

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??? DatetimePicker image in winform

Upvotes: 7

Views: 11153

Answers (2)

Behrooz Moghaddam
Behrooz Moghaddam

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

im_shidi
im_shidi

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

Related Questions