in

dotNetFreak

Ramblings & Controls from a .NET Addicted Freak!

Kevin Gearing's Blog

September 2005 - Posts

  • DateTimePicker Problems

    I've just stumbled across a couple of great problems with the default WinForms DateTimePicker control:

    Within an application I'm building I need to be able to represent a NullDate. Previously I've always used Date.MinValue to indicate whether or not a date has been specifyed, but after data binding a date property to the DateTimePicker I suddenly found out that Date.MinValue = 00:00:00 01/01/0001, and the DateTimePicker only supports dates after 00:00:00 01/01/1753.

    Fair enough I thought I can understand the logic in that (kind of), so I created a constant within my application called 'NullDate' that returns 00:00:00 01/01/1800, which whilst it isn't ideal, does solve the problem.

    But now I have the problem that the DateTimePicker (even though it's being fed a 4 digit year), believes that 00:00:00 01/01/1800 actually equals 00:00:00 01/01/2000. Argh! Now I need to figure out why! I could understand it if I was passing in a 2 digit date, but not a 4 digit one.

    I'll update this post if/when I find a solution.

    UPDATE:

    Right it looks like it's to do with the property being databound to an object. If I set the 'Value' or 'Text' property manually it displays the correct date, however when an object is databound to the 'Text' property it shows the wrong century. I'm guessing that the DateTimePicker is performing Property.ToString() to get the value from the object rather than Property.ToString(CustomFormat), i.e. Property.ToString("dd/MM/yyyy").

    RESOLVED:

    Change the 'Short Date' settings on the machine to dd/MM/yyyy instead of the UK default of dd/MM/yy.

  • My 3 Pet Peeves with Visual Studio 2003

    I know there are probably a lot more I could come up with, but these are my top 3 that I really hope Microsoft have fixed/resolved in Visual Studio 2005.


    1. Why oh why when you open a solution with multiple projects, including a handful of setup projects does VS feel like it has to expand all of the setup projects? It doesn't do it with any other project type. No matter what I do it ALWAYS expands them.


    2. Pinning the toolbox on some/most occasions hangs VS, the only resolution is to 'End Task'. Has this ever been fixed? Why does it always seem to happen when I REALLY don't want it to? Does VS have some built in sick sense of humour??


    3. Opening some/most help items from the index takes forever. Normally I have time to make a coffee and come back to my desk before it's opened. This can't be related to the performance of the machine either as it took the same time on my old PC as it does on my new one. Anyone know of a resolution to this? Resolved (see below)


    Argh!

Copyright ©2004-2007 Kevin Gearing. All Rights Reserved.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems