Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

I need help in Date picker control.

Here is my requirement, i have two controls 1) combobox with all the years listed and 2) a button next to combo box. if i select a year and click on button then user needs to see the months only in that year. user should not be able to navigate to next year.

Any idea how can we achieve this? please help me out.

ex. user selects 2009 and clicks on button then a calander control needs to be displayed with months from jan 2009 to dec 2009. user can't be able to navigate to jan 2010. user can be able to navigate between months of 2009.

thanks,
Mohan
Posted

1 solution

In the SelectedIndexChanged event of your combobox, set the MinDate and MaxDate property of your DateTimePicker. Like this:

yourDatePicker.MinDate = new DateTime(selectedYearFromDropDown, 1, 1);
yourDatePicker.MaxDate = new DateTime(selectedYearFromDropDown, 12, 31);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900