我一直在用Label控件创建滚动字幕文本她是样品code
I have been create Marquee text using Label control her is sample code
public partial class FrmMarqueeText : Form
{
private int xPos = 0, YPos = 0;
public FrmMarqueeText()
{
InitializeComponent();
}
private void FrmMarqueeText_Load(object sender, EventArgs e)
{
lblText.Text = "Hello this is marquee text";
xPos = lblText.Location.X;
YPos = lblText.Location.Y;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
if (xPos == 0)
{
this.lblText.Location = new System.Drawing.Point(this.Width, YPos);
xPos = this.Width;
}
else
{
this.lblText.Location = new System.Drawing.Point(xPos, YPos);
xPos -= 2;
}
}
但是当第一次结束了,但它并没有继续工作。请帮帮我!
but when the first time was finished, it didn't continues work .Please help me!
在timer1_Tick变化
In timer1_Tick change
if (xPos == 0)
到
if (xPos <= 0)
否则将无法工作,如果 this.Width
是奇数。