【发布时间】:2011-01-23 22:57:50
【问题描述】:
这是我的代码。当我将光标移到表格上时,它可以工作,圆圈正在移动,但它正在闪烁。我该如何解决这个问题?
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 已经提供了一个图形方法。
标签: c# winforms visual-studio-2010 drawing panel