日期:2014-05-18  浏览次数:21391 次

c# 画线怎么清屏
用c#   写了一个五子棋  
用  
protected   override   void   OnPaint(PaintEventArgs   e)  
{  
System.Drawing.Graphics   g   =   this.CreateGraphics();  
for   (int   x   =   0;   x   <   15;   x++)  
{  
for   (int   y   =   0;   y   <   15;   y++)  
{  
Box[y,   x]   =   Chess.None   ;//   }  

}  
//   base.OnPaint(e);  
Graphics   h   =   this.CreateGraphics();  
Pen   pen1   =   new   Pen(Color.Black,   1);  
for   (int   i   =   0;   i   <   15;   i++)  
{  
h.DrawLine(pen1,   40,   30   *   i   +   40,   460,   30   *   i   +   40);  
h.DrawLine(pen1,   30   *   i   +   40,   40,   30   *   i   +   40,   460);  
}  
pen1.Dispose();  
}  
画了棋盘图形  
棋子也是用Graphics   画的  
运行完一次之后  
屏幕上   刚刚下过的棋子没有删除  
没有办法继续下了  

有什么办法可以把上面的棋子删除  
把棋盘留下么??  

谢谢了各位

------解决方案--------------------
你重新定一个和棋盘图形一样的棋子A,如果你要删除那个棋子B,在B的位置把A重画一下就可以删除吧
------解决方案--------------------
在OnPaint方法里为什么还要调用CreateGraphics画建立Graphics呢?

使用e.Graphics不行吗难道!
------解决方案--------------------
你刷新重画就可以了,不过比较容易闪,据说能局部刷新,哪位大侠能具体解释解释啊!!
------解决方案--------------------
建议楼主看一下这个:

C#画图(WinForm)
http://blog.csdn.net/hbxtlhx/archive/2007/08/31/1766913.aspx
------解决方案--------------------
See:
【翻译】直线箭头和曲线箭头的绘制
http://bbs.msproject.cn/Default.aspx?g=posts&t=388