Results 1 to 13 of 13

Thread: NullableDateTimePicker for .NET 2.0

  1. #1

    Thread Starter
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    NullableDateTimePicker for .NET 2.0

    In .NET 1.1 I used to use the ExtendedDateTimePicker control from the Quantum Software Solutions Windows Forms Components library. Unlike some of their other components, the ExtendedDateTimePicker is not compatible with .NET 2.0, so I have created a control that works similarly, although not exactly the same way.

    Features:
    • Control is blank (instead of showing greyed text) when ShowCheckBox is true and Checked is false.
    • DataValue property allows you to assign null values.
    • DataValueChanged event is raised only when the DataValue property value changes.


    DataValue property:
    The main advantage of the DataValue property is that it allows you to bind the control to a database field and simply uncheck the control to assign a null value to the database. It accepts DateTime objects to set the date/time or a null reference or DBNull.Value to clear it. When cleared, the property always returns DBNull.Value. Note that if ShowCheckBox is false then assigning a null value to the DataValue property has no immediate effect, i.e. the control still displays text and the DataValue property still returns a DateTime object. If ShowCheckBox becomes true however, the change then becomes apparent, i.e. the control is blank and the DataValue property returns DBNull.Value. This means basically that if the control is intended to be able to contain a null value then ShowCheckBox must be true.

    DataValueChanged event:
    The ValueChanged event of the DateTimePicker is raised at times when the Value property value hasn't actually changed. In contrast, the DataValueChanged event of this NullableDateTimePicker is only raised when the DataValue property value has changed. This will occur if the ShowCheckBox is true and the DataValue property value changes from null to a date/time or a date/time to null, or else when the DataValue property value changes from one data/time value to another.

    If you use this code and find any issues please post here.

    Note that the attached code was originally written in C# and was converted using Instant VB from Tangible Software Solutions.
    Attached Files Attached Files

  2. #2
    New Member
    Join Date
    Jun 2008
    Posts
    1

    Re: NullableDateTimePicker for .NET 2.0

    This looks great - exactly what I need.
    I'm a bit of a beginner with VB .NET 2008.
    Ive copied your code into a class in my project but I'm not sure how to use the control in a form. I just drag an drop the datetimepicker from the datasource window. No doubt this is dead simple and I'm just being rather dim :-(

  3. #3

    Thread Starter
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: NullableDateTimePicker for .NET 2.0

    I'd actually suggest that you don't use this control. There's a bug in it that I didn't ever get around to fixing because QSS ended up releasing their WFC library for .NET 2.0. I'd suggest you follow that first link in the original post and get that.

  4. #4
    Junior Member
    Join Date
    Nov 2010
    Posts
    30

    Re: NullableDateTimePicker for .NET 2.0

    Jm, any new solutions for the DTP? I'm having the same problem, I can null a date in the sql server with code and it saves fine, it's just the DTP control, when it runs over a null record it shows the value of the previous record, btw, the DTP works fine in a datarepeater for me with the checkbox but I want to get away from the datarepeater, thanks dotnet 3.5sp1

  5. #5
    Hyperactive Member
    Join Date
    Mar 2013
    Location
    San Francisco, CA
    Posts
    487

    Re: NullableDateTimePicker for .NET 2.0

    jmc -

    I'd suggest you follow that first link in the original post and get that.
    I took a look at the website you're referencing. There's a download link for their "free" Windows Forms Components, but the link opens a page that only has their "paid" products. Are they still offering their nullable DTP control?

  6. #6

    Thread Starter
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: NullableDateTimePicker for .NET 2.0

    Quote Originally Posted by Mark@SF View Post
    jmc -



    I took a look at the website you're referencing. There's a download link for their "free" Windows Forms Components, but the link opens a page that only has their "paid" products. Are they still offering their nullable DTP control?
    I just followed the link in post #1 and it leads to the same page that it did all those years ago but I'm not sure that there's a public link to that page on their site any more. I haven't used any of those controls for a long time so I'm not sure of the status but it doesn't look good. You might like to email them and see what they have to say.

  7. #7
    Hyperactive Member
    Join Date
    Mar 2013
    Location
    San Francisco, CA
    Posts
    487

    Re: NullableDateTimePicker for .NET 2.0

    jmc -

    Thanks, I've emailed QSS and will let you know what I learn.

    In the meantime, have you fixed the bug in your NullableDateTimePicker (post #3)? If not, then do you have a suggestion for an alternative?

  8. #8
    Hyperactive Member
    Join Date
    Mar 2013
    Location
    San Francisco, CA
    Posts
    487

    Re: NullableDateTimePicker for .NET 2.0

    jmc -

    Just got a reply from QSS.

    Hello Mark,

    This product was discontinued some years ago. Did you by any chance purchase a source code license in the past?

    We could possibly still sell you a source code license if you are interested, but if you are simply after the Nullable DateTimePicker I would be surprised if there are no other solutions available (although I don’t immediately have a link to one).

    Just to confirm this is for Windows Forms, not WPF, correct (as the components were never compatible with WPF)?

    Regards,

    Edward Forgács
    Office: +61 2 8071 3100
    Fax: +61 2 8071 3180
    www.quantumsoftware.com.au
    Their Windows Forms Components library is no longer available.
    Last edited by Shaggy Hiker; May 31st, 2020 at 09:33 AM.

  9. #9

    Thread Starter
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: NullableDateTimePicker for .NET 2.0

    Quote Originally Posted by Mark@SF View Post
    In the meantime, have you fixed the bug in your NullableDateTimePicker (post #3)? If not, then do you have a suggestion for an alternative?
    I haven't and I don't. But I'm prepared to take another look at it. If you like, you can use the code as is and then I can hopefully provide a drop-in replacement in the next few days.
    Quote Originally Posted by Mark@SF View Post
    Just got a reply from QSS.

    Their Windows Forms Components library is no longer available.
    At least they got back to you promptly.

  10. #10
    Hyperactive Member
    Join Date
    Mar 2013
    Location
    San Francisco, CA
    Posts
    487

    Re: NullableDateTimePicker for .NET 2.0

    jmc -

    It would be nice to have a nullable DTP control. Thanks for your offer to update your control. I’m impressed that you are still interested in a year 2006 piece of code!

    I’ve looked through the CodeBank and searched the forums for information on a nullable DTP control. Lots of postings and discussion.

    In the past, I’ve used the DTP control along with a PictureBox with a calendar icon, a modal form (dialog), and a TextBox. I only use the DTP as a “picker” - it’s not bound to anything. The user clicks the PictureBox to open a dialog that has the DTP, then picks a date. When the dialog is closed, the selected date is placed in the TextBox. I bind the TextBox.Text property to the date field (DataColumn) and set the DataSourceUpdateMode property to OnValidation. In the TextBox.Validated event I push DBNull.Value to the BindingSource if the TextBox.TextLength = 0. Otherwise, I push CDate(TextBox.Text) to the BindingSource. I use the TextBox.Tag property to keep the original date and if the user enters an invalid date directly into the TextBox, then I use the TextBox.Validating event to cancel the user's data entry and restore the original date.

    A nullable DTP control that would simplify the above steps (multiple controls, a form, 2 events, etc.) would be nice to have.
    Last edited by Mark@SF; May 31st, 2020 at 09:50 AM.

  11. #11
    Hyperactive Member
    Join Date
    Mar 2013
    Location
    San Francisco, CA
    Posts
    487

    Re: NullableDateTimePicker for .NET 2.0

    jmc -

    I'm prepared to take another look at it
    Just checking back in w/you on this topic...any progress?

  12. #12

    Thread Starter
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: NullableDateTimePicker for .NET 2.0

    Quote Originally Posted by Mark@SF View Post
    jmc -



    Just checking back in w/you on this topic...any progress?
    Sorry, I have a habit of intending to get back to these things and their getting lost in the shuffle. It's on the list.

  13. #13
    Hyperactive Member
    Join Date
    Mar 2013
    Location
    San Francisco, CA
    Posts
    487

    Re: NullableDateTimePicker for .NET 2.0

    Thanks 👍

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