Click here to Skip to main content
15,867,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to set datetime picker month from april to next year march but we can select any year or day from datetimepicker, month only restrict there .

What I have tried:

C#
DateTimePicker dtp = sender as DateTimePicker;
DateTime april = DateTime.Today.Date;
if (dateTimePicker1.Value < april)
{
   MessageBox.Show("You are not allowed to select older day than today!");
   //unregister the handler first
   dtp.ValueChanged -= dateTimePicker1_ValueChanged;
   //set the value
   dateTimePicker1.Value = DateTime.Today.Date;
   //register handler again
   dtp.ValueChanged += dateTimePicker1_ValueChanged;
}
else
{
   //If selected date is today or up, do something.
}

but this one is not effective ,its give only current year or month
Posted
Updated 21-Aug-18 21:56pm
v2
Comments
Herman<T>.Instance 22-Aug-18 7:26am    
c#? or is this AJAX ControlToolkit?
Member 13854008 23-Aug-18 6:32am    
it's c# (windows application)

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