我正在使用Visual Studio 2010并在c#中编写一个简单的项目。我有一个图片框和两个按钮。当按下一个按钮时,图片框中的图像会发生变化,但我无法更改背景图片布局属性。在按钮回调是这样的:PictureBox.BackgroundImageLayout更改失败
pictureBox1.BackgroundImage = Image.FromFile("test.jpg");
pictureBox1.BackgroundImageLayout = ImageLayout.Stretch;
图像被改变,但它没有延伸到图片框。实际上,只显示了适合图片框的图像的一部分。
有什么建议吗?
UPDATE
这是我的错误。在按钮回调调用竟是:
pictureBox1.Image = Image.FromFile("test.jpg");
pictureBox1.BackgroundImageLayout = ImageLayout.Stretch;
,而不是上发言。
尝试调用'pictureBox1.Refresh();' –