Brad
Brad

Reputation: 21210

looking for a month/year selector control for .net winform

I am looking for a month selector control for a .net 2 winform.

Upvotes: 17

Views: 24076

Answers (1)

Donut
Donut

Reputation: 112895

Use DateTimePicker. You can use a custom format to enable just the month and year to be specified.

Example:

DateTimePicker dateTimePicker1 = new DateTimePicker();
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "MM yyyy";
dateTimePicker1.ShowUpDown = true; // to prevent the calendar from being displayed

See this MSDN article for more information.

Edit:
To prevent the calendar from being displayed, set the ShowUpDown property on the DateTimePicker to true. This will prevent the calendar from being displayed and (in conjunction with a CustomFormat) allow you to set just the month and year by using the up/down buttons.

Upvotes: 46

Related Questions