Thoughts from Dan Miser RSS 2.0
 Thursday, November 24, 2005
When using a DateTimePicker control, MS assumes that the numeric part groupings (i.e. hour, minutes, seconds, etc.) are entered using 2 digit numbers. However, this means that the text in the control and the DateTime property can often get out of sync.

Take the example where you are just editing a Time and the text of the control is set to "12:00:00 PM". At this point, the DateTime and the text are the same. If you edit the '12' portion by typing '8', no OnChange event occurs, and furthermore, if you try to evaluate the DateTime property at this point it will still be the value for '12:00:00 PM' (e.g. Use a TSpeedButton to evaluate the property since it doesn't make the DateTimePicker lose focus). If you were to type '08' instead, things would be fine. Also, if you were to use the arrow keys to select the minutes part, or tab out of the control, things would be fine. It's just the one case I mentioned above that doesn't work like I would expect.

In order to solve this for my needs, I just did a DateTimePicker1.Perform(WM_KILLFOCUS, 0, 0) before evaluating the DateTime property. Since the control was on a popup window that was going away anyway, any side-effects of doing this won't really apply.

Thursday, November 24, 2005 11:21:00 AM (Central Standard Time, UTC-06:00)  #    Comments [2] -

Tracked by:
http://9qi-information.info/03072533/allevamento-pesce-tropicali.html [Pingback]
http://9oe-information.info/13794979/how-much-does-a-sports-brodcaster-get-paid.... [Pingback]
http://9qf-information.info/28072638/index.html [Pingback]
http://9qm-information.info/72892095/centro-commerciale-piemonte.html [Pingback]
http://9qf-information.info/08773753/index.html [Pingback]
http://9op-information.info/59965704/index.html [Pingback]
http://9ob-information.info/49506500/index.html [Pingback]
http://9qh-information.info/89207059/index.html [Pingback]
http://9rk-information.info/42460156/ohio-mi-paper-company.html [Pingback]
http://9rk-information.info/13174327/choral-music-gifts.html [Pingback]
http://9ry-information.info/73057841/index.html [Pingback]
http://9rf-information.info/72242898/index.html [Pingback]
http://9ry-information.info/56489394/index.html [Pingback]
http://9sd-information.info/28543469/index.html [Pingback]
http://9rm-information.info/64935721/index.html [Pingback]
http://9uafk-le-informazioni.info/39056005/copertina-cd-tutto-scorre.html [Pingback]
http://9uaep-le-informazioni.info/27425712/rotolo-asciugamano-sanarol-2-velo-lib... [Pingback]
http://9uafq-le-informazioni.info/03002095/index.html [Pingback]
http://9uaeg-le-informazioni.info/34065853/index.html [Pingback]
http://9uafc-le-informazioni.info/73325995/por-para-ejercicios.html [Pingback]
http://9uaek-le-informazioni.info/69800878/index.html [Pingback]
http://9uaee-le-informazioni.info/72869618/inviti-x-festa-di-compleanno.html [Pingback]
http://9uaep-le-informazioni.info/76669837/ace-brain.html [Pingback]
http://9uafa-le-informazioni.info/71975685/index.html [Pingback]
http://9uahb-le-informazioni.info/92429843/index.html [Pingback]
http://9uahk-le-informazioni.info/77178697/index.html [Pingback]
http://9uahi-le-informazioni.info/98531797/vacanza-berenice-egitto.html [Pingback]
http://9uahi-le-informazioni.info/45079106/index.html [Pingback]
http://9uahp-le-informazioni.info/77301711/index.html [Pingback]
http://9uago-le-informazioni.info/90127616/8-8.html [Pingback]
http://9uahr-le-informazioni.info/05812840/index.html [Pingback]
http://9uagl-le-informazioni.info/33432046/index.html [Pingback]
http://9uago-le-informazioni.info/02018366/index.html [Pingback]
Monday, November 28, 2005 2:17:00 PM (Central Standard Time, UTC-06:00)
I see what you are saying. This is also an issue in .net, however there is no Perform method to resolve in this manner. I suppose one could use interop to import the .dll function:

const int WM_KILLFOCUS = 0x0008;

[DllImport("User32.dll", EntryPoint = "SendMessage")]

private static extern int SendMessage(int hWnd,

int Msg,

int wParam,

int lParam);

Then, call

SendMessage(dateTimePicker1.Handle.ToInt32(), WM_KILLFOCUS, 0, 0);

where appropriate. Or alternatively force the user to validate.
Steve Mariucci
Monday, July 24, 2006 6:47:00 AM (Central Standard Time, UTC-06:00)
Is there a setting for switching the region of datetime picker?
Comments are closed.
Navigation
Archive
<November 2008>
SunMonTueWedThuFriSat
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2008
Dan Miser
Sign In
Statistics
Total Posts: 310
This Year: 25
This Month: 0
This Week: 0
Comments: 605
All Content © 2008, Dan Miser
DasBlog theme 'Business' created by Christoph De Baene (delarou)