更改Picturebox图像,C#

时间:2015-02-26 21:14:21

标签: c# winforms picturebox

我要做的是改变我的图片框'在代码中的图像,我不知道语法,并为它找了很多但是找不到它。请解释,因为我是C#的新手,所有的帮助表示赞赏

感谢您的阅读。

1 个答案:

答案 0 :(得分:2)

    // Construct an image object from a file in the local directory.
    // ... This file must exist in the solution.
    Image image = Image.FromFile("myLocalImage.png");
    // Set the PictureBox image property to this image.
    // ... Then, adjust its height and width properties.
    pictureBox1.Image = image;
    pictureBox1.Height = image.Height;
    pictureBox1.Width = image.Width;