简体   繁体   中英

Scaling picturebox size to picture

On my Picture box the images shown always appear in a specific height and width shown below:

        private void lstpic_SelectedIndexChanged(object sender, EventArgs e)
        {
        picbox.ImageLocation = @"C:\Pics\" + (string)lstpic.SelectedItem;
        picbox.Height = 768;
        picbox.Width = 1024;

I have set the height and width here, but this only controls the picturebox's height and width, so if I make it smaller each image has part of it cut off. Is there a way I can scale the images instead so they show completely just in a smaller size, rather re sizing the picturebox.

试试pictureBox1.SizeMode属性

              picbox.SizeMode = PictureBoxSizeMode.StretchImage;

似乎工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM