Casa Jonsson

Nils & Araceli’s home on the web, est. 2003

26  11 2003

You can pick your dates, and you can pick your nose, but …

I’ve written a new technical article for The Code Project. As of this writing, feedback’s positive—21 users have given the article an average rating of 4.68 out of 5, and it’s been viewed nearly 3,000 times. end of entry


8 Responses to “You can pick your dates, and you can pick your nose, but …”

  1. Hi Nils,

    Thanks very much for the article about the DateTimeSlicker. For us the datetimeslicker is the datetime control we where waiting for. We still have one question: we’d like to set the backcolor of the control. The .NET DateTime control does not support this feauture. Do you have some code to achieve this, of have any direction in how to solve this issue ?

    Thanks a lot

    Richard Weening

    (the Netherlands)

  2. Richard, no doubt you’ve discovered that you can set the BackColor property of DateTimePicker because it is inherited from Control, but doing so has no visible effect. DateTimePicker apparently uses SystemColors.Window to paint its background regardless of the value of its BackColor property.

    I fear that monkeying with DateTimePicker’s paint logic would be more trouble than its worth, and maybe impossible. This is because so much of this is handled under the covers in the internal, non-managed System.Windows.Forms classes SafeNativeMethods and UnsafeNativeMethods.

  3. Hello Nils,
    I’ve just read Your article on CodeProject. I must say, I did it with great hope because for the last few days I’ve been wasting my time on one problem that emerged from results of my work on DBNull values in DateTimePicker. My solution (based on the same mechanism as Your’s i.e. on special Formating for null values) however, not so advanced, caused strange behavior so I tried to use Your code instead. Unfortunatelly the results were the same.
    Let me explain the problem.
    1. There’s no problem (;-) at all when I use only one control.
    2. When there are to DateTime*icker controls bound to the two different columns of the same Table, they flicker interchangebly. During changing the position in DataSet (DataGrid — is also bound to this table) — when one displays the proper value, the other becomes empty (as if it had a DBNull value). Notice, that there are no (db)null values in data rows.
    It looks as if there were some race conditions (I hope it’s so called in English) or … maybe some unsynchronized calls (but why) ???. I don’t know. I figured that there may be sth wrong with setting new format values, but I don’t know why yet. Have You ever experienced such problem ?Thanks in advance, best regards, Przemek.

  4. I have not run across this problem, but I’ve never tried to bind two DateTimePickers to the same table. It does sound like a race condition. Most unfortunate. There’s little chance I’ll work on that because threading issues are a dadaistic nightmare to debug, especially when we’re not fixing the original source but only overriding it.

  5. Thank You for the reply.
    If only I manage to solve this problem — I’ll let You know. Best regards, PM

  6. Hey,

    The DateTimePicker you made is a good idea, so I tried it and came up with the folowing remarks/problems : (Same problems occur in your demo)
    - When you go to the DataBinding Tab of your demo you can select values from the listbox and they come correctly in de DateTimeSlicker control. When you want to modify a “NOT NULL” value you can do it, but if you select a Null entry in your listbox, and you want to enable the dateTimeSlicker and enter a value, it’s impossible to do that. You just can’t enable the datetimeslicker anymore. Any suggestions, or am I the only one with that problem ?

    greetz
    Kristof;

  7. That’s very good lesson for me — “don’t ask before you completely recognize the problem”.
    It was not the matter of changing the position, but of the refilling the data set. (I’m sorry, but I trusted sb. I should have not). Anyway, it’s still the problem — but now easy to overcome. When I set all DateTime* controls to null before calling Fill… in the DataAdapter everything goes fine.
    Thanks for Your help,
    regards,
    Przemek.

  8. Thanks for the great control. It’s hard to believe the checked property could work so poorly (and they don’t even provide an event for it! come on!).

    I’ve posted a comment on codeproject that has a few small changes that enables databinding to work properly. Just thought you might want to propagate the changes back into the main src.

    Cheers,
    Britt

« 28 days later … Google puts us in our place »