문제

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.

도움이 되었습니까?

해결책

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top