如题,代码如下
private void button3_Click(object sender, EventArgs e)
{
Graphics mygraph = this.button4.CreateGraphics();
mygraph.DrawLine(new Pen(Color.Blue, 5), 167, 12, 290, 12);
mygraph.DrawLine(new Pen(Color.Blue, 5), 167, 12, 220, 63);
mygraph.DrawLine(new Pen(Color.Blue, 5), 290, 12, 232, 63);
}
点击button3后线画出来了,但几秒后自动消失了。什么原因,谢谢
private void button3_Click(object sender, EventArgs e)
{
Graphics mygraph = this.button4.CreateGraphics();
mygraph.DrawLine(new Pen(Color.Blue, 5), 167, 12, 290, 12);
mygraph.DrawLine(new Pen(Color.Blue, 5), 167, 12, 220, 63);
mygraph.DrawLine(new Pen(Color.Blue, 5), 290, 12, 232, 63);
}
点击button3后线画出来了,但几秒后自动消失了。什么原因,谢谢
解决方案 »
- Socket 编程,一个服务器,多个客户端,互相通信(分享)
- 正则表达式问题
- 请教一下各位,tif图片在picturebox里面加载的问题
- 为什么我在IE9里面截获有COOKIE而我无法模拟
- (Winfom) 为什么TextBox的值总是不变???
- C# 中类似VB中 With end With 的语句是什么?
- 100分求live communication server的开发资料
- 如何在winform中DataGrid点击某行,使数据实时显示在TEXTBOX中?散分50!
- 关于,进程的问题
- 怎样才为之精通c#(或c++)?
- 大家看看这个木马怎么写?
- 在VS2005下如何部署应用程序到没有装.NET FRAMWORK的机器上?
private void button3_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawLine(new Pen(Color.Blue, 5), 167, 12, 290, 12);
e.Graphics.DrawLine(new Pen(Color.Blue, 5), 167, 12, 220, 63);
e.Graphics.DrawLine(new Pen(Color.Blue, 5), 290, 12, 232, 63);
}
base.OnPaint(e);
Graphics mygraph = this.button4.CreateGraphics();
mygraph.DrawLine(new Pen(Color.Blue, 5), 167, 12, 290, 12);
mygraph.DrawLine(new Pen(Color.Blue, 5), 167, 12, 220, 63);
mygraph.DrawLine(new Pen(Color.Blue, 5), 290, 12, 232, 63);
Onpaint事件 也就是说你话的图 窗体没有记忆住,它只根据他自己的Onpaint函数进行绘制,如果你想在这种条件下显示你自己的图片,就要重写Onpaint函数(在里面加上你的绘图语句)
{
base.OnPaint(e);
Graphics mygraph = this.button5.CreateGraphics();
mygraph.DrawLine(new Pen(Color.Blue, 5), 167, 12, 290, 12);
mygraph.DrawLine(new Pen(Color.Blue, 5), 167, 12, 220, 63);
mygraph.DrawLine(new Pen(Color.Blue, 5), 290, 12, 232, 63);
}
这样吗?那我button3_click里面就不用改了?我想在button3_click把图画出来