0

I have been working on a windows forms game in visual studio, it's pretty basic, but i'm mostly making it to learn more about C#. Anyway, in the main dungeon for the game, I drew a basic tile, and put it on a tiling picture box. In the inspector, it looks good, the tile is the same size as the player image, and the tiles line up with the edge of the picture box. However, once I hit play, the tiles auto scale, and become far too large, they don't fit with the character, and more importantly, they don't line up with the picture box. I have spent probably an hour and a half scanning through the inspector tools looking for a way to fix this weird error, but I can't seem to find anything.

I am wondering if there is any way to code in the tile attributes to make it work out. I have attached a picture of before I hit play (left), and after (right) so you guys get a better idea of what exactly I mean. Any fix would be greatly appreciated.enter image description here

vvvvv
  • 25,404
  • 19
  • 49
  • 81
acornTime
  • 278
  • 1
  • 15
  • 2
    Use the Anchor properties. Sometimes the Dock style, too. Overall, you need to accommodate the end user's different visual settings. – LarsTech Nov 12 '19 at 00:16
  • 2
    [How to configure an app to run correctly on a machine with a high DPI setting (e.g. 150%)?](https://stackoverflow.com/a/13228495/7444103). Note that Image DPI can play a role. When your app is DPIAware, you can read the actual DPI of the device where your Form is shown. You can use both the [Form].DeviceDpi property and the Graphics object's DpiX and DpiY properties. The Bitmap's Dpi values contribute to describe how an Image is rendered in a specific device context. – Jimi Nov 12 '19 at 01:34
  • 1
    As you mentioned, you used a picturebox to show "tile", maybe you can try to its `SizeMode` to `StretchImage`. – 大陸北方網友 Nov 12 '19 at 01:47
  • Thank you to everyone who answered, my visual studio was resizing itself in the edit mode, so I changed that setting everything works now. – acornTime Nov 21 '19 at 15:28
  • Kyle Wang, I used tile rather than stretch image because I drew one tile and I wanted the background to look like a tile floor. – acornTime Nov 21 '19 at 15:28

1 Answers1

0

Thank you to everyone who answered, my visual studio was resizing itself in the edit mode, so I changed that setting everything works now.

acornTime
  • 278
  • 1
  • 15