2012-04-13 72 views
18

如何將Datetimepicker -Format設置爲MM/YYYY?如何將Datetimepicker設置爲僅月和年格式?

+1

喜見鏈接 – 2012-04-13 07:50:50

+1

查看答案,看看這裏也; http://www.geekzilla.co.uk/View00FF7904-B510-468C-A2C8-F859AA20581F.htm – 2012-04-13 07:52:53

+1

[尋找.net winform的月/年選擇器控件](http://stackoverflow.com/問題/ 1608792 /尋找一個爲期一年的選擇器控制網絡winform) – 2012-04-16 07:56:14

回答

43

使用DateTimerPicker.Format屬性。檢查MSDN

public void SetMyCustomFormat() 
{ 
    // Set the Format type and the CustomFormat string. 
    dateTimePicker1.Format = DateTimePickerFormat.Custom; 
    dateTimePicker1.CustomFormat = "MM/yyyy"; 
} 
+0

感謝它的工作! – asdasdad 2012-04-13 07:51:28

8

您可以使用DateTimerPicker.Format屬性如下:

DateTimerPicker.Format = DateTimePickerFormat.Custom; 
DateTimerPicker.CustomFormat = "MMMM yyyy"; 
DateTimerPicker.ShowUpDown = true; 

注:DateTimerPicker.ShowUpDown = true;是製作日曆不可見

相關問題