HighTechTalks DotNet Forums  

Location in DateTimePicker

Dotnet Framework (WinForms Controls) microsoft.public.dotnet.framework.windowsforms.controls


Discuss Location in DateTimePicker in the Dotnet Framework (WinForms Controls) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Richard MSL
 
Posts: n/a

Default Location in DateTimePicker - 12-26-2007 , 05:54 PM






I am using a DateTimePicker control to allow users to input dates. My users
have asked for a number entry mode, where they can use the numeric keypad to
key in 122607 for December 26, 2007, for example. The DateTimePicker control
does not support this, but I have been able to somewhat write my own, using
KeyUp, KeyPress and KeyDown. It enables the user to set the month by pressing
a key, such as J for January.

But in order to implement numeric entry, I need to know where in the field
the input cursor is - on the month, day or year segment. And there does not
appear to be a DateTimePicker member that gives that. So my question is, how
can my KeyDown method determine where the input cursor is in the field, so
that I can program it accordingly? Thanks.


Reply With Quote
  #2  
Old   
Jeffrey Tan[MSFT]
 
Posts: n/a

Default RE: Location in DateTimePicker - 12-27-2007 , 03:24 AM






Hi Richard,

DateTimePicker control did not expose any programming interface to
determine the highlitting part. This state is maintained by the
DateTimePicker internally.

If you really wanted to get this done, the only thought I can think of is
calculating the location yourself. For example, the initial focuses is the
first part of these three parts(Year, Month, Day) in DateTimPicker, then
you may handle both MouseClick and KeyDown events and track any focus
change in these three parts. The keyboard navigation should be easy to
track; you may just take care of the left/right keys and update your own
data structure to reflect that another part is focused because of the
keyboard navigation.

The hard part is the mouse click. It is easy to get the mouse click
position in MouseClick event, but there is no support interface to query
the focus rectangle of these three parts. However, we need these three
rectangle location information to perform hit testing. Currently, I still
can not think of a way to retrieve this information. So there may be no
good solution to your requirement.

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
  #3  
Old   
VisualHint
 
Posts: n/a

Default Re: Location in DateTimePicker - 12-27-2007 , 10:21 AM



Hello Richard,

if you are trying to do this with the MS DateTimePicker you will lose
a lot of time. The native API don't do that and you will need a lot of
hacks to achieve what you want, if ever feasible. And what if you
later change the format of the displayed date?

This is because the DTP has so many limitations and I wanted a
flexible DTP in Smart PropertyGrid that I developed Smart
FieldPackEditor.Net. It is a powerful component that lets you edit any
field based data, like a date, a position, an ip address and so on. If
a commercial component is an option, you could have a look at it, it
does exactly what you want.

Best regards,

Nicolas Cadilhac @ VisualHint (http://www.visualhint.com)
Home of Smart FieldPackEditor.Net / DateTimePicker replacement (http://
www.visualhint.com/index.php/fieldpackeditor)
Home of Smart PropertyGrid for .Net and MFC (http://www.visualhint.com/
index.php/propertygrid)
Microsoft PropertyGrid Resource List - http://www.propertygridresourcelist.com


On Dec 26, 5:54 pm, Richard MSL <RichardKirkn... (AT) nospam (DOT) nospam> wrote:
Quote:
I am using aDateTimePickercontrol to allow users to input dates. My users
have asked for a number entry mode, where they can use the numeric keypad to
key in 122607 for December 26, 2007, for example. TheDateTimePickercontrol
does not support this, but I have been able to somewhat write my own, using
KeyUp, KeyPress and KeyDown. It enables the user to set the month by pressing
a key, such as J for January.

But in order to implement numeric entry, I need to know where in the field
the input cursor is - on the month, day or year segment. And there does not
appear to be aDateTimePickermember that gives that. So my question is, how
can my KeyDown method determine where the input cursor is in the field, so
that I can program it accordingly? Thanks.


Reply With Quote
  #4  
Old   
Richard MSL
 
Posts: n/a

Default RE: Location in DateTimePicker - 12-27-2007 , 10:17 PM



Thanks for the help, both answers point to me using a different date time
picker control, either one I write, or one that I purchase. Thanks.

""Jeffrey Tan[MSFT]"" wrote:

Quote:
Hi Richard,

DateTimePicker control did not expose any programming interface to
determine the highlitting part. This state is maintained by the
DateTimePicker internally.

If you really wanted to get this done, the only thought I can think of is
calculating the location yourself. For example, the initial focuses is the
first part of these three parts(Year, Month, Day) in DateTimPicker, then
you may handle both MouseClick and KeyDown events and track any focus
change in these three parts. The keyboard navigation should be easy to
track; you may just take care of the left/right keys and update your own
data structure to reflect that another part is focused because of the
keyboard navigation.

The hard part is the mouse click. It is easy to get the mouse click
position in MouseClick event, but there is no support interface to query
the focus rectangle of these three parts. However, we need these three
rectangle location information to perform hit testing. Currently, I still
can not think of a way to retrieve this information. So there may be no
good solution to your requirement.

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



Reply With Quote
  #5  
Old   
Jeffrey Tan[MSFT]
 
Posts: n/a

Default RE: Location in DateTimePicker - 01-02-2008 , 09:45 PM



Hi Richard,

Thanks for the feedback.

Yes, the build-in DateTimePicker does not support your requirement, so
purchasing a 3rd-party customized control may be necessary. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.