How to clear dateTimePicker in vb.net.....-VBForums
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
    #28 for the Yanks coming GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    6,900

    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
    #28 for the Yanks coming GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    6,900

    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
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,267

    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...
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  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
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,267

    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..
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  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
    Frenzied Member kaliman79912's Avatar
    Join Date
    Jan 2009
    Location
    Ciudad Juarez, Chihuahua. Mexico
    Posts
    1,983

    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
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.