473,406 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

DateTimePicker Parts

Is there a way, via code, to modify which portion of the
DateTimePicker control is selected when the control gets
focus? For example, if the control contains 12/25/2003,
could the portion that is selected be the Day (25) portion
of the control?
Jul 21 '05 #1
8 2266
Hello Dave,

Thanks for your post. Based on my experience and research, DateTimePicker
does not provide any property/method to set/get the selected portion of
Date text. To work around this problem, I suggest that you can handle the
ValueChanged event and ensure that a user can only change the Day portion
of the control.

DateTimePicker.ValueChanged Event
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemwindowsformsdatetimepickerclassvaluecha ngedtopic.asp

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #2
Hello Dave,

Thanks for your post. Based on my experience and research, DateTimePicker
does not provide any property/method to set/get the selected portion of
Date text. To work around this problem, I suggest that you can handle the
ValueChanged event and ensure that a user can only change the Day portion
of the control.

DateTimePicker.ValueChanged Event
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemwindowsformsdatetimepickerclassvaluecha ngedtopic.asp

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #3
Hi Dave,

Thanks for your feedback. When your DatePicker control is got focused, you
may try generating a mouse click message at the left of the control in
order to put the cursor there.

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #4
Sounds great! What is the sample code?
-----Original Message-----
Hi Dave,

Thanks for your feedback. When your DatePicker control is got focused, youmay try generating a mouse click message at the left of the control inorder to put the cursor there.

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
.

Jul 21 '05 #5
Hi Dave,

You can use P/Invoke to call unmanaged API SendInput() which synthesizes
mouse clicks. Please tell me what programming language you are using so
that I will try to write some sample code snippet.

SendInput
http://msdn.microsoft.com/library/de...us/winui/WinUI
/WindowsUserInterface/UserInput/KeyboardInput/KeyboardInputReference/Keyboar
dInputFunctions/SendInput.asp?frame=true

I look forward to your reply.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #6
Using VB.NET. Really appreciate your help!
-----Original Message-----
Hi Dave,

You can use P/Invoke to call unmanaged API SendInput() which synthesizesmouse clicks. Please tell me what programming language you are using sothat I will try to write some sample code snippet.

SendInput
http://msdn.microsoft.com/library/default.asp? url=/library/en-us/winui/WinUI/WindowsUserInterface/UserInput/KeyboardInput/KeyboardInp utReference/KeyboardInputFunctions/SendInput.asp?frame=true

I look forward to your reply.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
.

Jul 21 '05 #7
Hello Dave,

Thanks for your response. The following sample suppose that you the
DateTimePicker is of "Short" format(12/25/2003 ) and it post mouse click
messages to the begining of the control (x=6, y=6) so that the month (12)
will be selected whenever it got focus.

'-------------------------------code snippet----------------------------
Declare Auto Function PostMessage Lib "user32" Alias "PostMessageA"
(ByVal hwnd As IntPtr, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal
lParam As Int32) As Int32
Public Const MK_LBUTTON = &H1
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Private Sub DateTimePicker1_GotFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DateTimePicker1.GotFocus
Dim lParam As Int32
lParam = 393222 ' equals to C code "MAKELPARAM(6,6)"
PostMessage(DateTimePicker1.Handle(), WM_LBUTTONDOWN, MK_LBUTTON,
lParam)
PostMessage(DateTimePicker1.Handle(), WM_LBUTTONUP, 0, lParam)
End Sub
'--------------------------------end of-------------------------------------

Please check it on your side.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #8
Perfect!!! Thanks a bunch!
-----Original Message-----
Hello Dave,

Thanks for your response. The following sample suppose that you theDateTimePicker is of "Short" format(12/25/2003 ) and it post mouse clickmessages to the begining of the control (x=6, y=6) so that the month (12)will be selected whenever it got focus.

'-------------------------------code snippet------------- --------------- Declare Auto Function PostMessage Lib "user32" Alias "PostMessageA"(ByVal hwnd As IntPtr, ByVal wMsg As Int32, ByVal wParam As Int32, ByVallParam As Int32) As Int32
Public Const MK_LBUTTON = &H1
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Private Sub DateTimePicker1_GotFocus(ByVal sender As Object, ByVal e AsSystem.EventArgs) Handles DateTimePicker1.GotFocus
Dim lParam As Int32
lParam = 393222 ' equals to C code "MAKELPARAM (6,6)" PostMessage(DateTimePicker1.Handle(), WM_LBUTTONDOWN, MK_LBUTTON,lParam)
PostMessage(DateTimePicker1.Handle(), WM_LBUTTONUP, 0, lParam) End Sub
'--------------------------------end of------------------ -------------------
Please check it on your side.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
.

Jul 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Angelina | last post by:
Hi, I have got two DateTimePicker's on my form to accept a guest arrival date and departure date.what i want to acheieve is ensure that the DateTimePicker2 (departure) is always greater than...
9
by: Guy | last post by:
I have extended the datetimepicker control to incorporate a ReadOnly property. I have used the new keyword to implement my own version of the value property, so that if readonly == true then it...
0
by: Sumit | last post by:
Hi all, I have a datetimepicker on my windows form. When the user selects it i check whether the date entered is a Sunday or not & if its not a sunday i want that the control remains on the...
4
by: Jacek Jurkowski | last post by:
.... the minimum date of DateTimePicker is 1753-01-01. How to make DateTime to do not show nothing in its text if this date is the value? I have a form with a field LastLogonDate. If user hasn't...
7
by: Clamara | last post by:
When adding a new record from my form, I pre-set my DateTimePicker's value to System.DateTime.Today Since the "Today" value is used most of the time, the user doesn't need to select a date from...
3
by: Charlie | last post by:
In the top portion of the DateTimePicker, where the value of the date is displayed, how can I detect whether the month or day or year is currently focused, or, if ShowCheckBox = True, whether the...
7
by: Dave | last post by:
Is there a way, via code, to modify which portion of the DateTimePicker control is selected when the control gets focus? For example, if the control contains 12/25/2003, could the portion that is...
3
by: Simon Tamman | last post by:
I've come across an interesting bug. I have workarounds but i'd like to know the root of the problem. I've stripped it down into a short file and hope someone might have an idea about what's going...
5
by: Mike | last post by:
Hi, I use MS SQL Express and VS 2005 c#, win application. I would like to select value rom DateTimePicker and list all values for selected date within GridView. I have method as follows: ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.