views:

54

answers:

2

I want to set format of date to dd-mm-yyyy for control date time picker,i m able to create date time picker dynamically but can not set its format to dd-mm-yyyy plz do needful....

+2  A: 

Have you tried just setting the DateTimePicker.CustomFormat property?

picker.Format = DateTimePickerFormat.Custom;
picker.CustomFormat = "dd-MM-yyyy";

(Note the MM for months; mm is for minutes.)

Jon Skeet
thank you sir....Its working with slight change, dtp.Format = System.Windows.Forms.DateTimePickerFormat.Custom;dtp.CustomFormat ="dd-MM-yyyy";
Smack
kool...working for me too
Sangram
@Smack: Duly edited, thanks.
Jon Skeet
+1  A: 

Set format type to custom first:

DateTimePicker.Format = DateTimePickerFormat.Custom;

DateTimePicker.CustomFormat = "dd-MM-yyyy";

Andrei Bularca
thank u its working with change as dtp.Format = System.Windows.Forms.DateTimePickerFormat.Custom;dtp.CustomFormat ="dd-MM-yyyy";
Smack
With pleasure...
Andrei Bularca