Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 572983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:40:34+00:00 2026-05-13T13:40:34+00:00

I am implementing search functionality in WinForms and I search by date range. Thus

  • 0

I am implementing search functionality in WinForms and I search by date range. Thus there are dateForm and dateTo date pickers on the form. By default their values are date time now() and if user do not touch date time pickers at all he will not get any results. Because search will be performed between now() and now(), also if I put min and max values as default it would solve first problem but there would be another problem if user wants to search by date range, he would need to click many times to come from default 1700 (something) to now()

Any suggestions to solve this problem?

Thanks a lot.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T13:40:35+00:00Added an answer on May 13, 2026 at 1:40 pm

    You can’t have a valueless datepicker with the out-of-the-box control. Why? It is backed by DateTime, which is non-nullable.

    You can disable it with another control, or leave it disabled until the user clicks (bad UX for keyboard enthusiasts, like myself), or find or create (!) one that uses Nullable<DateTime>.

    Edit:

    In response to your comment, yes, you can do this; in fact, I’ve done it.

    • use fields or private properties to hold the ‘from’ and ‘to’ dates, instead of reading them from the dtp, and set their defaults to min and max
    • use a boolean flag to indicate when you are manipulating the dtp value in code, and in the dtp’s ValueChanged event, set the flag’s value to false
    • in the form load event, set the flag to true and dtp value to today’s date
    • also in the ValueChanged event, set the from and to fields to the values of the dtps (you have to set both when either dtp changes, because the user will see the other one as set to today, but the search value will still be min or max).

    The problems with this is that once the user has changed the date selection, she can’t easily go back to "all dates." Furthermore, the user can’t select "today only" without first changing one of the dates and then changing it back.

    I think the best solution for you is to have a checkbox, "search by date range," which either enables the two dtps that are otherwise disabled, or displays the dtps that are otherwise hidden. Then you search from min to max unless the checkbox is checked, and when the checkbox is checked, you use the two dtp dates no matter what they are. Don’t forget to deal with to and from being out of order, which can be done in several ways.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any microformat/standard for implementing search form on the site? (access keys, naming
I'm implementing full text search functionality on my rap website , and I'm running
I am implementing a search functionality in a website I am building, which involves
I'm implementing a faceted search functionality where the user can filter and drill down
I'm implementing a search feature for an app that uses entity framework. There are
I'm currently implementing a search form in our users database. I would like to
I am implementing Advanced Search kind of functionality for an Entity in my system
I am facing a problem in implementing the search functionality in Table Views... Here
I am implementing the search functionality through ajax jquery, though I am new in
In implementing faceted search, if the number of options is 7 or less, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.