我遇到了Picturebox(picWorld)的问题。当我想像这段代码一样改变它的大小和位置时,花了很多时间,因为我认为它正在更新两次:
private void lblWorld_MouseEnter(object sender, EventArgs e)
{
picWorld.Size = new Size(148, 148);
picWorld.Location = new Point(picWorld.Location.X - 12, picWorld.Location.Y - 12);
}
有没有办法让它更快?
答案 0 :(得分:0)
尝试隐藏它,移动它,然后显示它:
private void lblWorld_MouseEnter(object sender, EventArgs e)
{
picWorld.Hide();
picWorld.Size = new Size(148, 148);
picWorld.Location = new Point(picWorld.Location.X - 12, picWorld.Location.Y - 12);
picWorld.Show();
}
答案 1 :(得分:-1)
创建一个外部变量(首选静态)来存储何时开始和何时结束,所以:
bool now=false;
private void lblWorld_MouseEnter(object sender, EventArgs e)
{
if (!now)
{
now = true;
picWorld.Size = new Size(148, 148);
picWorld.Location = new Point(picWorld.Location.X - 12, picWorld.Location.Y - 12);
now = false;
}
}