title: Simulate Keyboard Event on Windows Mobile
body: <p>Please refer to the screenshot below:</p>
  
  <p>The datetime control is a Compact Framework DateTimePicker, the numbered buttons are stndard Button controls.</p>
  
  <p>Clicking on the arrow of the DateTimePicker displays a calendar control allowing the suer to select a date. However if the user clicks on any part of the selected Text date it is highlighted and can be amended using either the hard keys or the on-screen keyboard. I'm trying to emulate this functionality with my standard buttons.</p>
  
  <p>I've have tried the following but currently this is only causing the DateTimePicker to lose focus. </p>
  
  <pre><code>    const int KEYEVENTF_KEYUP = 0x2;
      const int KEYEVENTF_KEYDOWN = 0x0;
      const int VK_NUMPAD1 = 0x61;
  
      private void digitButton_Clicked(object sender, EventArgs e)
      {
          keybd_event(VK_NUMPAD1, 0, KEYEVENTF_KEYDOWN, 0);
          keybd_event(VK_NUMPAD1, 0, KEYEVENTF_KEYUP, 0);
      }
  
      [DllImport("coredll.dll", EntryPoint = "keybd_event", SetLastError = true)]
      public static extern void keybd_event
      (
      byte bVk,
          byte bScan,
      int dwFlags,
          int dwExtraInfo
      ); 
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/BVlBV.jpg" alt="DateTimePicker Keyboard"></p>