我想在c#的picturebox上画图
Point mypoint=new Point();
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
mypoint.X = e.X;
mypoint.Y = e.Y;
}
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
Graphics g = this.CreateGraphics();
SolidBrush sb = new SolidBrush(Color.Black);
Pen mypen = new Pen(sb, 2f);
g.DrawEllipse(mypen, mypoint.X - 1, mypoint.Y - 1, 20, 20);
}
为什么picturebox没有什么反应呢
再添加一句
Point mypoint=new Point();
bool isok;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
isok=true;
mypoint.X = e.X;
mypoint.Y = e.Y;
}
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
if(isok==true)
{ Graphics g = this.CreateGraphics();
SolidBrush sb = new SolidBrush(Color.Black);
Pen mypen = new Pen(sb, 2f);
g.DrawEllipse(mypen, mypoint.X - 1, mypoint.Y - 1, 20, 20);
}
}
但是picturebox没有什么反应呢