Click here to Skip to main content
15,923,789 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
i'm working in WPF in C#. i have two datepicker. and i want first datepicker days subtract 2nd datepicker. And first datepicker days is less for 2nd datepicker so message box show error. So what can i do.
Posted
Comments
Sergey Alexandrovich Kryukov 24-Apr-12 13:30pm    
Is your copy of MSDN broken? How about Google or Bing? Did they ban you? Sorry for you... :-)
--SA
S@53K^S 24-Apr-12 15:00pm    
Hilarious :-)

You mention a message box. I would recommend displaying an error message, or some similar why of showing there is an error (red broder on textboxes with errors and a tool tip). At the same time disable the user from pressing the OK button. Users are not real fond of message boxes. Some designers do everything they can to avoid message boxes.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 25-Apr-12 16:43pm    
That is a good point; even though it hardly related to the question, my 5.
--SA
I don't know what exactly date picker do you have, but they all should have something like Value property of the type System.DateTime,
http://msdn.microsoft.com/en-us/library/system.datetime.aspx[^].

And this type has subtraction operation defined. So, if you have two times, the difference can be found like this:
C#
System.DateTime t1 = //...
System.DateTime t2 = //...
System.TimeSpan = t2 - t1; //as simple as that; t1 - t2 is also valid


Finally, look at System.TimeSpan structure to see what is that:
http://msdn.microsoft.com/en-us/library/system.datetime.aspx[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900