绘制直线的重绘问题 我在做一个简单的画板,做到了绘制知道的地方,但是再画第二次直线的时候就会把前面的一条直线给擦掉,请问谁有关于直线重绘的代码,帮忙给我介绍一下呀,急需! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private void pictureBox1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { if (drawing) { Graphics g = this.pictureBox1.CreateGraphics(); Pen backPen = new Pen(this.pictureBox1.BackColor); g.DrawLine(backPen, this.start, this.end); this.end.X = e.X; this.end.Y = e.Y; Pen forePen = new Pen(Color.Blue); g.DrawLine(forePen, this.start, this.end); } }private void pictureBox1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { if (drawing) {Graphics g = this.pictureBox1.CreateGraphics(); Pen backPen = new Pen(this.pictureBox1.BackColor); g.DrawLine(backPen, this.start, this.end); this.end.X = e.X; this.end.Y = e.Y; Pen forePen = new Pen(Color.Blue); g.DrawLine(forePen, this.start, this.end); this.drawing = false; this.drawing = false; array.Add(new Rectangle(this.start, new Size(this.width, this.height)));} }这是我做的关于mousemove和mouseup的代码 每次都CreateGraphics,当然会被清除掉吧。改用Graphics g = Graphics.FromImage(pictureBox1.Image);这样试试。还有画完了别忘了g.Dispose(); 我还是新手,这个方法不懂,可不可以在我创建的代码的基础上写一下关于paint的重绘的代码呀? c# treeview建立树怎么显示好几个同样的根节点? 初学者遇到了麻烦,麻烦前辈们帮忙 如何设计时实数据动态曲线设计? 去的一个文件夹下的指定文件问题 C#中能开方吗? 获取的网页出现中文乱码,绝大部分正常,但总有极个地方出问题 c/s to b/s 关gridView中实现多列头的问题 如何设置datagrid中某一行的背景颜色和字体颜色? WinFrom下面的DataGridView绑定自定义字段的操作? DataGridView的一个小问题 请各位大神指教!
{
if (drawing)
{
Graphics g = this.pictureBox1.CreateGraphics();
Pen backPen = new Pen(this.pictureBox1.BackColor);
g.DrawLine(backPen, this.start, this.end);
this.end.X = e.X;
this.end.Y = e.Y;
Pen forePen = new Pen(Color.Blue);
g.DrawLine(forePen, this.start, this.end);
}
}
private void pictureBox1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (drawing)
{
Graphics g = this.pictureBox1.CreateGraphics();
Pen backPen = new Pen(this.pictureBox1.BackColor);
g.DrawLine(backPen, this.start, this.end);
this.end.X = e.X;
this.end.Y = e.Y;
Pen forePen = new Pen(Color.Blue);
g.DrawLine(forePen, this.start, this.end);
this.drawing = false; this.drawing = false;
array.Add(new Rectangle(this.start, new Size(this.width, this.height)));
}
}这是我做的关于mousemove和mouseup的代码
改用
Graphics g = Graphics.FromImage(pictureBox1.Image);
这样试试。还有画完了别忘了g.Dispose();