运动图像框计时器更快 [英] Moving Picture box with timer faster
问题描述
我在Compact Framework 2.0的C#
表格的一个项目,我使用了很多图片框,并且有一个定时器来改变pictureboxs的位置,每一秒钟,但移动很慢我怎么能做出更快呢?
计时器间隔为100
私人无效timer1_Tick(对象发件人, EventArgs五)
{
picust.Location =新的点(picust.Location.X,picust.Location.Y + 10);
picx.Location =新的点(picx.Location.X,picx.Location.Y + 10);
picy.Location =新的点(picy.Location.X,picx.Location.Y + 10);
}
由于您使用NET精简Framework 2.0中,你可以通过使用 <$改进代码C $ C> SuspendLayout 和 ResumeLayout
它支持2.0版本的启动方式。围绕把你的代码这些方法作为例子:
//假设这个代码是父窗体
内
私人无效timer1_Tick(对象发件人,EventArgs五)
{
this.SuspendLayout();
picust.Location =新的点(picust.Location.X,picust.Location.Y + 10);
picx.Location =新的点(picx.Location.X,picx.Location.Y + 10);
picy.Location =新的点(picy.Location.X,picx.Location.Y + 10);
this.ResumeLayout();
}
这将防止形式三个redrawings,而是只进行一次。
I have a project in Compact framework 2.0 C# I am using a lot of picturebox in Form and there is a timer to change the location of pictureboxs every second but moving is very slowly how can I make faster it?
Timer interval is 100
private void timer1_Tick(object sender, EventArgs e)
{
picust.Location = new Point(picust.Location.X, picust.Location.Y + 10);
picx.Location = new Point(picx.Location.X, picx.Location.Y + 10);
picy.Location = new Point(picy.Location.X, picx.Location.Y + 10);
}
Since you are using NET Compact Framework 2.0 you could improve your code by using SuspendLayout
and ResumeLayout
methods which are supported starting from version 2.0. Put these methods around your code as in the example:
//assuming that this code is within the parent Form
private void timer1_Tick(object sender, EventArgs e)
{
this.SuspendLayout();
picust.Location = new Point(picust.Location.X, picust.Location.Y + 10);
picx.Location = new Point(picx.Location.X, picx.Location.Y + 10);
picy.Location = new Point(picy.Location.X, picx.Location.Y + 10);
this.ResumeLayout();
}
This will prevent three redrawings of the form and instead perform only one.
这篇关于运动图像框计时器更快的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!