求助winform里的画线问题!
求助winform里的画线问题!
Graphics g = this.CreateGraphics();
g.DrawLine(Pens.Red,
new Point(pictureBox1.Bounds.X + pictureBox1.Bounds.Width / 2,
pictureBox1.Bounds.Y + pictureBox1.Bounds.Height / 2),
new Point(pictureBox2.Bounds.X + pictureBox2.Bounds.Width / 2,
pictureBox2.Bounds.Y + pictureBox2.Bounds.Height /2));
象这样连线两个picturebox,当把form最小化
或者有什么东西遮住一小会,线就消失了,
谁能帮帮我!让线坚持住!
------解决方案--------------------up
------解决方案--------------------在OnPaint事件中把你写的东西在写一遍就好了
------解决方案--------------------因为在重绘事件中你的线没有被重绘
所以线就没有了
------解决方案--------------------顶啊!
------解决方案--------------------比如:
private void picDraw_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawLine(Pens.Red, this.picDraw.ClientRectangle.Left, this.picDraw.ClientRectangle.Top, picDraw.ClientRectangle.Right, this.picDraw.ClientRectangle.Bottom);
}