PC Review


Reply
Thread Tools Rate Thread

DateTimePicker Parts

 
 
Dave
Guest
Posts: n/a
 
      17th Dec 2003
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?
 
Reply With Quote
 
 
 
 
Tian Min Huang
Guest
Posts: n/a
 
      18th Dec 2003
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/
frlrfsystemwindowsformsdatetimepickerclassvaluechangedtopic.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.

 
Reply With Quote
 
Tian Min Huang
Guest
Posts: n/a
 
      19th Dec 2003
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.

 
Reply With Quote
 
Guest
Posts: n/a
 
      22nd Dec 2003
Sounds great! What is the sample code?

>-----Original Message-----
>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.
>
>.
>

 
Reply With Quote
 
Tian Min Huang
Guest
Posts: n/a
 
      23rd Dec 2003
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.

 
Reply With Quote
 
Guest
Posts: n/a
 
      24th Dec 2003
Using VB.NET. Really appreciate your help!
>-----Original Message-----
>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/default.asp

url=/library/en-us/winui/WinUI
>/WindowsUserInterface/UserInput/KeyboardInput/KeyboardInp

utReference/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.
>
>.
>

 
Reply With Quote
 
Tian Min Huang
Guest
Posts: n/a
 
      25th Dec 2003
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.

 
Reply With Quote
 
dave
Guest
Posts: n/a
 
      26th Dec 2003
Perfect!!! Thanks a bunch!
>-----Original Message-----
>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.
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Serious issue: parts of my page render as not logged in, parts as logged in. Help! pcloches@gmail.com Microsoft ASP .NET 1 12th Apr 2007 01:50 AM
DateTimePicker =?Utf-8?B?ZnJlZGR5?= Microsoft VB .NET 2 5th Apr 2005 07:23 PM
DateTimePicker Saurabh Microsoft Dot NET Framework Forms 3 26th May 2004 10:11 AM
datetimepicker ichor Microsoft C# .NET 1 31st Mar 2004 09:07 AM
Datetimepicker =?Utf-8?B?SmFj?= Microsoft C# .NET 1 23rd Mar 2004 12:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:59 AM.