C# picturebox load image with an offset

后端 未结 4 1159
时光取名叫无心
时光取名叫无心 2020-12-19 14:32

I have a resource file (in .png format) which contain several images. They are sized and spaced in a way to where they should be relatively easy to call based on their offse

4条回答
  •  无人及你
    2020-12-19 15:07

    You can put the PictureBox in a Panel, using the panel as your viewport. Make sure the panel's AutoScroll property is false so you don't get scroll bars appearing. Then, load the image in the PictureBox, and set it's location relative to the Panel so only the area you'd like to show is visible.

    pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
    pictureBox1.Image = Image.FromFile(@"C:\MyPicture.png");
    pictureBox1.Location = new Point(-100, -100);
    

提交回复
热议问题