CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2012

    setting default DateTime control


    I have two dateTime controls, one for a start date of search and one for end date. I'm using the dates to search
    file creation dates and then storing them into a array. I would like to have the search include all files if a dateTime
    is not picked. Any suggestion about how to do this? Can you do it in the get; set ; ?

         public DateTime startDate
                get { return startDate; }
                set { startDate = value; }
            public DateTime endDate
                get { return endDate; }
                set { endDate = value; }
    Thanks for your time in this for me


  2. #2
    Join Date
    Oct 2003
    .NET2.0 / VS2005 Developer

    Re: setting default DateTime control

    Ahh,, the age old ugliness of a nullable date time picker rears its head again..

    But i've most often found it to be a better UI design decision to put a separate checkbox next to the picker, and enable/disable the picker (or change its customformat from space, to yyyymmdd and back again) when the checkbox is checked/unchecked, so that people more obviously know what theyre searching for

    When it comes time to do the query, if checkbox is not checked, pass DateTime.Min/MaxValue depending on whether it's the date from, or date to, that is checked:

    Avoid the temptation to set the picker value to DateTime.MinValue because it loses the users previous choice, and puts them back a huge number of years which makes the ui a nuisance for them to use

    The checkbox inside the picker is too small to be helpful/usable I think
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width