![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
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. |
#4
| |||
| |||
|
|
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. |
#5
| |||
| |||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |