这是我的代码。当我将光标移动到表单上时,它可以工作,圆圈在移动,但是会闪烁。我该如何解决这个问题?
public partial class Preprocesor : Form
{
int x, y;
Graphics g;
public Preprocesor()
{
InitializeComponent();
}
private void Preprocesor_Load(object sender, EventArgs e)
{
g = pnlMesh.CreateGraphics();
}
private void pnlMesh_Paint(object sender, PaintEventArgs e)
{
g.Clear(Color.White);
g.FillEllipse(Brushes.Black, x, y, 10, 10);
}
private void pnlMesh_MouseMove(object sender, MouseEventArgs e)
{
x = e.X;
y = e.Y;
pnlMesh.Invalidate();
}
}
Graphics
?PaintEventArgs 已经提供了一个 graphics 方法。 - Rye