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