title: resizing pictureBox proportionally to Form resizing
body: <p>I want everytime , the user resizes the Form , the Image in the pictureBox , also resizes with the same Values  ( proportionally ) , </p>
  
  <p>I searched on the internet for some codes and found this answer in <strong>StackOverFlow</strong>
  <a href="https://stackoverflow.com/a/6501997/3264464">https://stackoverflow.com/a/6501997/3264464</a></p>
  
  <pre><code>static public Bitmap ScaleImage(Image image, int maxWidth, int maxHeight)
  {
      var ratioX = (double)maxWidth / image.Width;
      var ratioY = (double)maxHeight / image.Height;
      var ratio = Math.Min(ratioX, ratioY);
      var newWidth = (int)(image.Width * ratio);
      var newHeight = (int)(image.Height * ratio);
      var newImage = new Bitmap(newWidth, newHeight);
      Graphics.FromImage(newImage).DrawImage(image, 0, 0, newWidth, newHeight);
      Bitmap bmp = new Bitmap(newImage);
      return bmp;
  }
  </code></pre>
  
  <p>I added the function for my code , and am not sure about the MaxHeight,MaxWidth thing , i mean why do i need to send it via parameters</p>
  
  <p>and In the <code>Form1_Resize</code> event handler i wrote:</p>
  
  <pre><code>private void Form1_Resize(object sender, EventArgs e)
  {
      Bitmap NewImg = ScaleImage(pictureBox1.Image, 1000, 1000);
      pictureBox1.Image = NewImg;
  }
  </code></pre>
  
  <p>but It won't work .. Nothing Happens when I resize the form</p>
  
  <p>UPDATE: Tried everything with same results</p>
  
  <p>Look at the pictures below , The black point is the Left of the PictureBox and it must not move , what you suggested is good , but i want , The left of the pictures stays on the same point at the beggining</p>
  
  <p><strong><em>Before Resize:</em></strong></p>
  
  <p><img src="https://i.stack.imgur.com/p8F92.png" alt="Before"></p>
  
  <p><strong><em>After Resize</em></strong></p>
  
  <p><img src="https://i.stack.imgur.com/FwhOn.png" alt="enter image description here"></p>