用词不是很准确啊,本人新手,刚学C#
用Point定义点,再动态画吧.
是不是这样?
private Point MousePoint;
private bool mouseDown = false;
private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(e.Button == MouseButtons.Left)
{
mouseDown = true;
MousePoint = new Point(e.X,e.Y);
}
}
private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(e.Button == MouseButtons.Left)
{
if(mouseDown)
{
Graphics g = this.CreateGraphics();
Pen p = new Pen(Color.Blue,2);
g.DrawLine(p,MousePoint.X,MousePoint.Y,e.X,e.Y);
MousePoint.X = e.X;
MousePoint.Y = e.Y;
p.Dispose();
g.Dispose();
}
}
}
private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
mouseDown = false;
}