本文介绍了使用标签控件创建在C#的winform循环滚动字幕文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在用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
是奇数。
这篇关于使用标签控件创建在C#的winform循环滚动字幕文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!