using Label control to create looping marquee text in c# winform

Posted by hanmyint on Stack Overflow See other posts from Stack Overflow or by hanmyint
Published on 2011-11-30T09:40:59Z Indexed on 2011/11/30 9:51 UTC
Read the original article Hit count: 234

Filed under:
|
|

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!

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET