-1

I have a problem with PictureBox in Microsoft Visual Studio. No matter what I do there is always border on top and bottom. It makes no difference even if I use a image of the same size as PictureBox. I'm using zoom property, so there should not be any changes in aspect ratio of the image. Dock is set to none and all padding variables are set to zero. Border is set to none.

I need a cursor position on a image, so I need to get rid of that borders because they shift the position.

Primoz
  • 1
  • 3
  • Mine by default has no border - so I cant reproduce your issue – BugFinder Apr 14 '16 at 09:48
  • Border it's actually not visible by default. I saw, that there is a problem when I created mouse down event. When I press the mouse button a short distance from the image upper or lower border event still happens, but the mouse pointer it's not positioned on image. I can actually see the border if I change the BackColor property. – Primoz Apr 14 '16 at 09:56
  • It's a Windows Form aplication. – Primoz Apr 14 '16 at 09:57
  • What you call 'border' really is the background. You are mistaken about the zoom property. And also probably about the size. Use the ClientSize to get the inner size and use Stretched to remove the borders, at the cost of, yup, stretching. Use First Autosize and then Normal after loading to avoid both, at the cost of changing the PB's size.. – TaW Apr 14 '16 at 10:06
  • Yes you are right it's not a border, but a background. How to get rid of it? I read the documentation of the zoom option and there is written: "The size of the image is increased or decreased maintaining the size ratio." So why there is a backgound visible if I have the same aspect ratio and the same size of an image and a PictureBox? I Will always have the same aspect ratio and I don't whant to use strecth because I need to transform the mouse position based on PictureBox to original image. – Primoz Apr 14 '16 at 10:15

1 Answers1

0

I successfully solved the problem. As advised I used strecth and then calculate the coordinates using ClientSize, current mouse pointer position and original image size. It works as it should.

For code sample you can refer to second answer here

Thank you very much for your help.

Community
  • 1
  • 1
Primoz
  • 1
  • 3