سؤال

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