How yo create a Typing Effect in Csharp

In this tutorial, we will learn how to create a program that animates a text using a label in C# Windows Form Application.

Create a New Project in C#, then Add 1 Label and 1 Timer. For the Label1 Text Property, change the fonts and size of your desired.


Open the code editor and type the code:

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

namespace TypingEffect
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        string typingtext = "code-devs.blogspot.com";
        static int index_Num = 0;

        private void timer1_Tick(object sender, EventArgs e)
        {
            label1.Text = typingtext.Substring(0, index_Num) + "_";
            index_Num++;
            if (index_Num == typingtext.Length + 1)
            {
            index_Num = 0;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            timer1.Interval = (150);
            timer1.Enabled = true;
            label1.Text = "";
        }
    }
}

After typing the code, press f5 or Run button to view the output.


How yo create a Typing Effect in Csharp How yo create a Typing Effect in Csharp Reviewed by code-dev on 3:16 PM Rating: 5

No comments:

Powered by Blogger.