title: PictreBox not being Placed as Predicted
body: <p>I have a large tile-based map created in a windows form.  Currently I am working in a 100 by 100 tile map (each tile is 50x50 pixels) by created by merging tile sprites into a large image and placing it in a picturebox the same size as the form.  One of the 
  abilities of this game is to place cities on this map in the form of  pictureboxes.  The
  problem comes when I try to enter a location for placement on the map.</p>
  
  <p>When I enter the desired grid location for a city when I am at the top left of the map, the city shows up as it should:<br>
  <a href="https://i.stack.imgur.com/Xl6Wu.png" rel="nofollow noreferrer">Entering coordinates without scrolling</a></p>
  
  <p><a href="https://i.stack.imgur.com/2HDgd.png" rel="nofollow noreferrer">Result of entering cooridnates without scrolling</a></p>
  
  <p>When I scroll in any way and try to place a city at the same location the form places city picturebox way off the map and stretches the form to fit where it thinks the city picturebox goes:</p>
  
  <p><a href="https://i.stack.imgur.com/KkDZc.png" rel="nofollow noreferrer">Entering coordinates with scrolling</a></p>
  
  <p><a href="https://i.stack.imgur.com/RYFHY.png" rel="nofollow noreferrer">The Forms stretches and places the city way off the map</a></p>
  
  <p>Here is the line of code I use for placing the city picturebox:</p>
  
  <pre><code>new_city.Location = new System.Drawing.Point(((add_city_x * 50)) + 20,
                                               ((add_city_y * 50)) + 20);
  </code></pre>
  
  <p>Where add_city_x and add_city_y are the coordinates inputted by the user, the *50 is the size of each tile, and the +20 is an offset for each tile to make room for a drop down menu.</p>
  
  <p>So far I have tried:</p>
  
  <ol>
  <li><p>Setting the maximum size of the picturebox.  The program still will stretch the form to add the picture box.</p></li>
  <li><p>Setting the border style.  This had the same affect as the previous trial.</p></li>
  <li><p>Compensating for where I am in the form by dividing the add_city *50 variable and dividing it by my current location in the form. (I am not sure if I did this correctly so further advice on this procedure may be helpful).</p></li>
  <li><p>Subtracting the form location form the calculation:  (add_city_x*50)-(this.Location.x*50)+20.  I did the same for the y-location, this did not help with the problem at all.  </p></li>
  </ol>
  
  <p>From what I have observed I know that the code computes the location calculation from the perspective of where I have scrolled to in the form. For instance, If I have scrolled half way across the form vertically and horizontally and then try to add a city to the map, the form will think that the location calculation begins at the top left of where I am rather than the top left of the form, resulting in the form being stretched to fit where the program thinks the city picturebox should be added. I'm looking for the calculation to run always from the upper left of the form instead of from wherever I have scrolled to on the screen.</p>