Saturday 3 May 2014

Moving text example in C#

Leave a Comment
This is a example of creating moving text in C#.
In order to do the moving text, you just need timer and label controller/component .


Steps by Step:

  1. Create one windows form project
  2. add one label in the form.
  3. copy and paste code below.
  4. Hit "CTRL + F5" and see what will happen.

The code :

    public partial class Form1 : Form
    {
        private string[] words = new string[3];
        private int i, j;
        public Form1()
        {
            InitializeComponent();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if(i.Equals(words[j].Length))
            {               
                label1.Text = "";
                if (j < words.Length - 1)
                {
                    j = j + 1;
                    label1.Text = words[j];
                }
                else
                {
                    j = 0;
                }
                i = 0;
            }
            label1.Text = words[j].Substring(0, i);
            i = i + 1;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            words[0] = "www.developersnote.com";
            words[1] = "www.developersnote.com";
            words[2] = "www.developersnote.com";
            timer1.Start();
        }
    }




By
NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)

0 comments:

Post a Comment

Subscribe to our newsletter to get the latest updates to your inbox.

Your email address is safe with us!




Founder of developersnote.com, love programming and help others people. Work as Software Developer. Graduated from UiTM and continue study in Software Engineering at UTMSpace. Follow him on Twitter , or Facebook or .



Powered by Blogger.