C#中:如何清空PictureBox中Image已画的图

smartDMer 2009-04-11 06:32:31
单击按钮后,显示了第一次画的图表,再次按按钮画新图时,原来的未清空,请大侠帮忙
private void button1_Click(object sender, EventArgs e)
{
Image Bmp = new Bitmap(1000, 700);
this.pictureBox1.Image = Bmp;
this.pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
Graphics gs = Graphics.FromImage(Bmp);
WellPMWork.gs = gs;
WellPMWork.Rander(); //实现画图的函数
}
我刚开始加了this.pictureBox1.Image = null; 但没用???
...全文
2593 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
jerry234 2010-05-10
  • 打赏
  • 举报
回复
把picturebox的visible=false,再visible=true。就可以了
penghuahua 2009-12-03
  • 打赏
  • 举报
回复
如果我不用list,只是单独的清空picturebox里的图片,如何解决?谢谢!
smartDMer 2009-04-15
  • 打赏
  • 举报
回复
谢谢你的回复,问题解决了.
在我的程序中有个List, 将List清空就行了
public WellPMWork WellPMWork = new WellPMWork();
ColumnData data = new ColumnData();
WellPMWork.Columns.Add(data);
在点击按钮事件中,清空List项
if (WellPMWork.Columns.Count != 0)
{
WellPMWork.Columns.Clear();//清空List进行重绘
}
Steve 2009-04-11
  • 打赏
  • 举报
回复
执行你的程序,拿别的窗口覆盖掉你的窗口,再回到你的窗口,画的东西还有吗?
smartDMer 2009-04-11
  • 打赏
  • 举报
回复
能讲得详细些吗?谢谢
Steve 2009-04-11
  • 打赏
  • 举报
回复
你这个切换到别的窗体以后画的图就没了吧,
在Paint里解决.

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧