Display Label Letter By Letter In C#

How To Show Label Letter By Letter Using C#

Display JLabel Letter By Letter Using C#


In This C# Tutorial we will see How To Show Label Text Letter By Letter Using Timer In CSharp Programming Language.


Project Source Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        int counter = 0;
        int len = 0;
        string txt;

        private void Form1_Load(object sender, EventArgs e)
        {
            txt = label1.Text;
            len = txt.Length;
            label1.Text = "";
            timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            counter++;

            if(counter > len)
            {
                counter = 0;
                label1.Text = "";
            }

            else {

                label1.Text = txt.Substring(0, counter);

                if (label1.ForeColor == Color.Black)
                    label1.ForeColor = Color.Red;
                else
                    label1.ForeColor = Color.Black;
            }
            
        }
    }
}




Share this

Related Posts

Previous
Next Post »