471,349 Members | 1,427 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

DateTimePicker DropDown

Is there a way to programatically tell the DateTimePicker control to drop down?

My form needs the date to be selected, and whenever it is "rolled up," it is
less obvious for my operators to see.
Jul 24 '08 #1
3 5860
On Jul 25, 12:48*am, jp2msft <jp2m...@discussions.microsoft.com>
wrote:
Is there a way to programatically tell the DateTimePicker control to dropdown?

My form needs the date to be selected, and whenever it is "rolled up," itis
less obvious for my operators to see.
try the following code

[DllImport("user32.dll")]
private static extern bool PostMessage(
IntPtr hWnd, // handle to destination window
Int32 msg, // message
Int32 wParam, // first message parameter
Int32 lParam // second message parameter
);

const Int32 WM_LBUTTONDOWN = 0x0201;

private void dateTimePicker1_MouseEnter(object sender, EventArgs e)
{
Int32 x = dateTimePicker1.Width - 10;
Int32 y = dateTimePicker1.Height / 2;
Int32 lParam = x + y * 0x00010000;

PostMessage(dateTimePicker1.Handle, WM_LBUTTONDOWN, 1,
lParam);
}

The above code is in MouseEnter event, If you want datetime picker
dropped down by default, try putting the code in Form_Load insted of
MouseEnter.

Hope this will help.

-Cnu
Jul 25 '08 #2
On Jul 25, 12:48*am, jp2msft <jp2m...@discussions.microsoft.com>
wrote:
Is there a way to programatically tell the DateTimePicker control to dropdown?

My form needs the date to be selected, and whenever it is "rolled up," itis
less obvious for my operators to see.
[DllImport("user32.dll")]
private static extern bool PostMessage(
IntPtr hWnd, Int32
msg, Int32 wParam, Int32
lParam
);

const Int32 WM_LBUTTONDOWN = 0x0201;

private void Form1_Load(object sender, EventArgs e)
{
Int32 x = dateTimePicker1.Width - 10;
Int32 y = dateTimePicker1.Height / 2;
Int32 lParam = x + y * 0x00010000;

PostMessage(dateTimePicker1.Handle, WM_LBUTTONDOWN, 1,
lParam);
}

Hope this will do.
-Cnu
Jul 25 '08 #3
Nice API Call there, Duggi. Thanks!

Do you know off hand which parameter below made my left mouse button hot,
though?

After sending the WM_LBUTTONDOWN message to the system, every place I moved
my mouse over on the Calendar caused something to happen. Most noticably,
whenever my mouse hovered above the Month Selectors, the months changed -
same with the year.

"Duggi" wrote:
[DllImport("user32.dll")]
private static extern bool PostMessage(IntPtr hWnd, Int32 msg,
Int32 wParam, Int32 lParam);
const Int32 WM_LBUTTONDOWN = 0x0201;
private void Form1_Load(object sender, EventArgs e) {
Int32 x = dateTimePicker1.Width - 10;
Int32 y = dateTimePicker1.Height / 2;
Int32 lParam = x + y * 0x00010000;
PostMessage(dateTimePicker1.Handle, WM_LBUTTONDOWN, 1, lParam);
}

Hope this will do.
-Cnu
Jul 25 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Barkster | last post: by
4 posts views Thread by Jordi Rico | last post: by
1 post views Thread by mfleet1973 | last post: by
2 posts views Thread by Michel Vanderbeke | last post: by
1 post views Thread by Dave Anson | last post: by
4 posts views Thread by jehugaleahsa | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.