I should have pointed out that this is a simple method that will work as
long as the F4 key is not being used as a shortcut to something else, like a
menu item. If this is the case then you could always PInvoke SendMessage and
send the message directly to the control.
using System.Runtime.InteropServices;
private const int WM_KEYDOWN = 0x0100;
private const int VK_F4 = 0x73;
[DllImport("User32.dll")]
private static extern int SendMessage(IntPtr hWnd, int iMsg, int wParam, int
lParam);
private void button1_Click(object sender, System.EventArgs e)
{
this.dateTimePicker1.Focus();
SendMessage(this.dateTimePicker1.Handle, WM_KEYDOWN, VK_F4, 0);
}
--
Tim Wilson
.Net Compact Framework MVP
{cf147fdf-893d-4a88-b258-22f68a3dbc6a}
Tim Wilson said:
The DateTimePicker will display it's calendar when it receives an F4
keypress. So you can simulate this by setting focus to the DateTimePicker
and then sending it an F4.
private void button1_Click(object sender, System.EventArgs e)
{
this.dateTimePicker1.Focus();
SendKeys.Send("{F4}");
}