i am writing a desktop application in c# using VS2013. I am getting an absurd error that has not to be produced, in my opinion. I am setting a DateTimePicker's MinDate and MaxDate properties somewhere in the code in such way:
DateTime minDate = DateTime.Parse(...);
DateTime maxDate = DateTime.Parse(...);
...
if (maxDate < dtpManuelFirst.MinDate)
{
dtpManuelFirst.MinDate = minDate;
dtpManuelFirst.MaxDate = maxDate;
}
else
{
if (minDate > dtpManuelFirst.MaxDate)
{
dtpManuelFirst.MaxDate = maxDate;
dtpManuelFirst.MinDate = minDate;
}
else
{
dtpManuelFirst.MinDate = minDate;
dtpManuelFirst.MaxDate = maxDate;
}
}
Very initially i know that minDate value is always less than maxDate value. When minDate is bigger than dtpManuelFirst.MaxDate like the second if condition, it updates the MaxDate property with no problem whereas i get the error "value is not valid for MinDate. MinDate must be less than MaxDate." on updating the MinDate property. It is ridiculous since i am already checking these conditions. In addition, the values are not supporting the error when i check in debug mode. Any help would be great!