bool G_MouseFlag; Pen pen = new Pen(Color.Black); Point lastPoint; private void _018_MouseMove(object sender, MouseEventArgs e) { Graphics graphics = this.CreateGraphics(); if (lastPoint.Equals(Point.Empty))//判断绘图开始点是否为空 { lastPoint = new Point(e.X, e.Y);//记录鼠标当前位置 } if (G_MouseFlag)//开始绘图 { Point currentPoint = new Point(e.X, e.Y);//获取鼠标当前位置 graphics.DrawLine(pen, currentPoint, lastPoint);//绘图 } lastPoint = new Point(e.X,e.Y);//记录鼠标当前位置 } private void _018_MouseDown(object sender, MouseEventArgs e) { G_MouseFlag = true;//开始绘图标识设置为true } private void _018_MouseUp(object sender, MouseEventArgs e) { G_MouseFlag = false;//开始绘图标识设置为false } //画圆 private void button1_Click(object sender, EventArgs e) { Graphics graphics = this.CreateGraphics(); Rectangle gle=new Rectangle(20,20,200,200); graphics.DrawEllipse(pen,gle); }