在button2 事件中,怎么不能用invalidate()啊,用了,在画别的就画不出来了;
请同志们帮帮忙啊,
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics g=e.Graphics;
g.FillRectangle(Brushes.GreenYellow,60,60,100,100);
}private void button1_Click(object sender, System.EventArgs e)
{
Graphics g1;
g1=this.CreateGraphics();
g1.FillRectangle(Brushes.Brown,70,70,20,20);
}private void button2_Click(object sender, System.EventArgs e)
{
this.Invalidate();//////???????加上为什么旧不显示下边的内容了啊
Graphics g;
g=this.CreateGraphics();
g.FillRectangle(Brushes.Blue,100,100,20,20);
}
请同志们帮帮忙啊,
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics g=e.Graphics;
g.FillRectangle(Brushes.GreenYellow,60,60,100,100);
}private void button1_Click(object sender, System.EventArgs e)
{
Graphics g1;
g1=this.CreateGraphics();
g1.FillRectangle(Brushes.Brown,70,70,20,20);
}private void button2_Click(object sender, System.EventArgs e)
{
this.Invalidate();//////???????加上为什么旧不显示下边的内容了啊
Graphics g;
g=this.CreateGraphics();
g.FillRectangle(Brushes.Blue,100,100,20,20);
}
解决方案 »
- 这段代码是否有有内存泄露,我走这个函数服务器内存就不断增加,只执行一次
- 关于方法返回结果问题—— return
- 拖动窗体MOUSEUP怎么写,用什么方法?
- winform程序打包
- 用 c# 作即时通讯的问题,老不明白
- asp.net中如何显示登录者的信息
- RM文件如何转换成ASF文件?
- 根据datagridview的某列的cell值,给另外一列的cell赋值(各位兄弟姐妹乱入)
- 请教,想我这样如何排列数组,谢谢!
- 求推荐屏幕键盘控件
- 未处理的“System.OutOfMemoryException”类型的异常出现在system.windows.forms.dll中
- 如何使用XmlReader.ReadSubtree方法!紧急求教!
Rectangle rect = new Rectangle(1,1,100,100);
Color color = Color.Red;
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
if(rect != null)
{
e.Graphics.FillRectange(new SolidBrush(color),rect);
}
}private void button1_Click(object sender, System.EventArgs e)
{
color = Color.Brown;
rect = new Rectangle(70,70,20,20);
this.Invalidate();
}private void button2_Click(object sender, System.EventArgs e)
{
color = Color.Blue;
rect = new Rectangle(70,70,20,20);
this.Invalidate();
}
Graphics g;
g=this.CreateGraphics();
g.FillRectangle(Brushes.Blue,100,100,20,20);
这三行代码要执行在 paint 事件之前啊,如果是的 话,怎样让它在paint 事件之后运行啊?????????????????
{
this.Invalidate();//////???????加上为什么旧不显示下边的内容了啊
Graphics g;
g=this.CreateGraphics();
g.FillRectangle(Brushes.Blue,100,100,20,20);
}
应该把this.Invalidate();放在函数末尾吧.