Pregunta

I want to disable the past days in date time picker control...they must be appear on the calender but they are in disable state.I am tried...but the all past days are disappeared from the calender.any idea.. My code is:

dateTimePicker1.MinDate = DateTime.Now.Date;

thanks.

¿Fue útil?

Solución

Try to Use Following :

dateTimePicker1.MinDate = new DateTime(year, month,day);
dateTimePicker1.MaxDate = new DateTime(year, month,day);
dateTimePicker1.ShowUpDown = true;
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "MMMM dd";

To disable Days before the first day of current month:

dateTimePicker1.MinDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);

Limit Future Date :

MaxDate is used as follows

dateTimePicker1.MaxDate = DateTime.Now.AddDays(number of days);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top