且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使Datetimepicker独立于我的Winform应用程序中的系统日期格式

更新时间:2023-10-09 17:19:22

我已经解决了这个问题。在将日期插入表格之前,以及每当我想根据sysytem更改格式的地方时,我都会通过此代码更改它并且

  String  date = MyDate.Text; 
DateTime paydate = Convert.ToDateTime(date,System.Globalization.CultureInfo.GetCultureInfo( hi-IN 跨度>)DateTimeFormat);


I am using DateTimePicker , i set it's customFormat property to dd/MM/yyyy. In the system i have the format M/d/yyyy. How can i make the DateTimePicker independent from the systems one.

I have tried statements like

    MyDate.Format = DateTimePickerFormat.Custom;
    MyDate.CustomFormat="dd/MM/yyyy";
but it's doesn't work.

I have solved this . Before insert date in to table, and every where when i want to change format according sysytem then i changed it by this code and
String date = MyDate.Text;
DateTime paydate =Convert.ToDateTime(date,System.Globalization.CultureInfo.GetCultureInfo("hi-IN").DateTimeFormat);