title: Trigger button click in .NET Compact Framework
body: <p>Say I have a Panel with many Button and PictureBox controls. Each control has an associated Click event. This is a touchscreen application, so the user may be a little imprecise with their click (or the touchscreen calibration might not be perfect). So, I'd like to handle the click event on the panel and then programmatically call the Button's or PictureBox's Click event if the click is close to a button/picture.</p>
  
  <p>A number of other answers suggest using the "PerformClick" event, but this is not supported in the Compact Framework. Any alternatives? My code:</p>
  
  <pre><code>private void pnlButtons_Click(object sender, EventArgs e)
  {
      Point ptClick = Control.MousePosition;
      foreach (Control cntrl in pnlButtons.Controls)
      {
          // Make sure the control is visible!
          if (cntrl.Visible)
          {
              // Click close to control?
              if ((ptClick.X &gt; (cntrl.Left - 5)) &amp;&amp;
                  (ptClick.X &lt; (cntrl.Right + 5)) &amp;&amp;
                  (ptClick.Y &gt; (cntrl.Top - 5)) &amp;&amp;
                  (ptClick.Y &lt; (cntrl.Bottom + 5)))
              {
                  // Click Button or PictureBox without cntrl.PerformClick?
              }
          }
      }
  }
  </code></pre>