清除Picturebox.backgroundimage中的c#
我有一个picturebox,可以将图像加载到它的.backgroundimage函数中,现在我有了一个按钮,可以清除图像,但不能。我已尝试使用此代码: secondcapturebox.Dispose(); 但这张照片仍在图片盒中。 请帮忙 谢谢你试过了吗清除Picturebox.backgroundimage中的c#,c#,background-image,picturebox,C#,Background Image,Picturebox,我有一个picturebox,可以将图像加载到它的.backgroundimage函数中,现在我有了一个按钮,可以清除图像,但不能。我已尝试使用此代码: secondcapturebox.Dispose(); 但这张照片仍在图片盒中。 请帮忙 谢谢你试过了吗 secondcapturebox.BackgroundImage = null; 你试过 secondcapturebox.BackgroundImage = null; 您必须将其设置为null。像这样: private vo
secondcapturebox.BackgroundImage = null;
你试过
secondcapturebox.BackgroundImage = null;
您必须将其设置为null。像这样:
private void button1_Click(object sender, EventArgs e) {
if (pictureBox1.BackgroundImage != null) {
pictureBox1.BackgroundImage.Dispose();
pictureBox1.BackgroundImage = null;
}
}
您必须将其设置为null。像这样:
private void button1_Click(object sender, EventArgs e) {
if (pictureBox1.BackgroundImage != null) {
pictureBox1.BackgroundImage.Dispose();
pictureBox1.BackgroundImage = null;
}
}
你选错了答案。不要因为尝试Dispose()时它不起作用而忽略它。您选择了错误的答案。不要因为尝试Dispose()时它不起作用而绕过它。欢迎使用StackOverflow!您的答案可能会受益于一点解释,为什么以及如何解决这个问题的代码。欢迎使用StackOverflow!您的答案可能会从一个小的解释中受益,这个代码为什么以及如何解决这个问题。