c# - ridicilous mindate maxdate error while settting datetime -
i writing desktop application in c# using vs2013. getting absurd error has not produced, in opinion. setting datetimepicker's mindate , maxdate properties somewhere in 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 know mindate value less maxdate value. when mindate bigger dtpmanuelfirst.maxdate second if condition, updates maxdate property no problem whereas error "value not valid mindate. mindate must less maxdate." on updating mindate property. ridiculous since checking these conditions. in addition, values not supporting error when check in debug mode. great!
the end result of decisions setting
dtpmanuelfirst.mindate = mindate; dtpmanuelfirst.maxdate = maxdate;
why not immediately? you don't need if-else branches when same thing anyway.
if still getting problems, set dtpmanuelfirst.maxdate
first large first.
dtpmanuelfirst.maxdate = datetime.maxvalue; dtpmanuelfirst.mindate = mindate; dtpmanuelfirst.maxdate = maxdate;
Comments
Post a Comment