Results 1 to 11 of 11

Thread: How to clear dateTimePicker in vb.net.....

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2008
    Posts
    60

    Unhappy How to clear dateTimePicker in vb.net.....

    Hi dudes...
    I want to build a query such that if no date is selected in datetimepicker all records must be displayed, if user select date then record with that date must be displayed.

  2. #2
    Addicted Member
    Join Date
    Sep 2008
    Location
    Jacksonville, Florida
    Posts
    147

    Re: How to clear dateTimePicker in vb.net.....

    dateTimePicker doesn't have a null or nothing value.
    vb.net and C# in 2008 .net 3.5
    ImaginaryDevelopment blog

  3. #3
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,495

    Re: How to clear dateTimePicker in vb.net.....

    Look at the check property of the the datetime picker. If check you use the date selected if not you ignore it
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  4. #4
    Addicted Member
    Join Date
    Sep 2008
    Location
    Jacksonville, Florida
    Posts
    147

    Re: How to clear dateTimePicker in vb.net.....

    Quote Originally Posted by GaryMazzone
    Look at the check property of the the datetime picker. If check you use the date selected if not you ignore it
    I just dropped a datetimePicker on a form.. and by default the checked property already says true even if the user has not selected anything yet.

    I'm in 2005, not sure about OP, or replies.
    vb.net and C# in 2008 .net 3.5
    ImaginaryDevelopment blog

  5. #5
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,495

    Re: How to clear dateTimePicker in vb.net.....

    So what I did was place it on the form. On the form load event I set it to Unchecked. When a user selects a date in the control it gets checked automaticaly.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  6. #6
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: How to clear dateTimePicker in vb.net.....

    Quote Originally Posted by MaslowB
    I just dropped a datetimePicker on a form.. and by default the checked property already says true even if the user has not selected anything yet.

    I'm in 2005, not sure about OP, or replies.
    Change the "ShowCheckbox" property to true to actually see the checkbox, then toggling the "checked' property will actually disable the control when its unchecked...

  7. #7
    Addicted Member
    Join Date
    Sep 2008
    Location
    Jacksonville, Florida
    Posts
    147

    Re: How to clear dateTimePicker in vb.net.....

    Quote Originally Posted by kleinma
    Change the "ShowCheckbox" property to true to actually see the checkbox, then toggling the "checked' property will actually disable the control when its unchecked...
    Boy is that handy, never noticed it. Thanks.
    vb.net and C# in 2008 .net 3.5
    ImaginaryDevelopment blog

  8. #8

    Thread Starter
    Member
    Join Date
    Dec 2008
    Posts
    60

    Re: How to clear dateTimePicker in vb.net.....

    Quote Originally Posted by kleinma
    Change the "ShowCheckbox" property to true to actually see the checkbox, then toggling the "checked' property will actually disable the control when its unchecked...

    Thnks dude,,,,,,it worked..........

  9. #9
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: How to clear dateTimePicker in vb.net.....

    It isn't ideal.. A nullable datetimepicker would be very nice to have, but until we see that (which is likely never) we use the checkbox approach..

  10. #10
    New Member
    Join Date
    Oct 2013
    Posts
    1

    Re: How to clear dateTimePicker in vb.net.....

    It’s late, but here is the answer (I am using 2010, vb.net)
    1. Set DateTimePicker Format property to custom
    2. Place combobox over the DateTimePicker
    3. In the code:
    Private Sub cmbBlankDate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbBlankDate.Click
    cmbFromBlankDate.Visible = False
    FromDateTimePicker.Visible = True
    End Sub

    Private Sub DateTimePicker_MouseCaptureChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker.MouseCaptureChanged

    cmbFromBlankDate.Visible = True
    FromDateTimePicker.Visible = False

    End Sub

  11. #11
    PowerPoster kaliman79912's Avatar
    Join Date
    Jan 2009
    Location
    Ciudad Juarez, Chihuahua. Mexico
    Posts
    2,593

    Re: How to clear dateTimePicker in vb.net.....

    Do you think is late? only 5 years late. LOL. But I appreciate your hack. (not really for it but some may)
    More important than the will to succeed, is the will to prepare for success.

    Please rate the posts, your comments are the fuel to keep helping people

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