title: How to zoom in using Mouse Position on that image
body: <p>I have a userControl library, which consists of the main Panel and a PictureBox, I want to make a zoomable PictureBox tool, I zoom in and out using mouseWheel event of the main Panel, the problem that I can't figure out how do I zoom in by the mouse position on the image, so whenever I zoom in, the zoom goes the Top-Left corner of the panel, so how do I fix that?</p>
  
  <pre><code>private double ZOOMFACTOR = 1.15;   // = 15% smaller or larger
  private int MINMAX = 5;
  void picPanel_MouseWheel(object sender, MouseEventArgs e)
      {
          if (e.Delta &gt; 0)
          {
              ZoomIn();
          }
          else
          {
              ZoomOut();
          }
      }
  
      private void ZoomIn()
      {
          if ((picBox.Width &lt; (MINMAX * this.Width)) &amp;&amp;
              (picBox.Height &lt; (MINMAX * this.Height)))
          {
              picBox.Width = Convert.ToInt32(picBox.Width * ZOOMFACTOR);
              picBox.Height = Convert.ToInt32(picBox.Height * ZOOMFACTOR);
          }
      } 
      private void picBox_MouseEnter(object sender, EventArgs e)
      {
          if (picBox.Focused) return;
          picBox.Focus();
      }
  </code></pre>
  
  <p><strong>Update :</strong></p>
  
  <p>I have tried this, it looks like working, but not exactly as it should be!! Any ideas?</p>
  
  <pre><code>    private void ZoomIn()
      {
          if ((picBox.Width &lt; (MINMAX * this.Width)) &amp;&amp;
              (picBox.Height &lt; (MINMAX * this.Height)))
          {
              picBox.Width = Convert.ToInt32(picBox.Width * ZOOMFACTOR);
              picBox.Height = Convert.ToInt32(picBox.Height * ZOOMFACTOR);
  
              Point p = this.AutoScrollPosition;
              int deltaX = e.X - p.X;
              int deltaY = e.Y - p.Y;
              this.AutoScrollPosition = new Point(deltaX, deltaY);
          }
      } 
  </code></pre>