How To Make Typing Effect In C#

typing thingy
Everyone wants the typing effect in their about form of their program even i want :) , so i found a very good way to do that thing easily .

First of all create a new project to test this & add a label from the toolbox because we need it also add a timer to the form . Don't change change anything in the timer properties , Now let's create a String and a Static Integer .
string Type_Text = "Ultimate programming tutorials";//This is the text that's going to be typed
   static int index_Num = 0;//declaring integer index_Num 
Now on form_load event let's code some basics
            timer1.Interval = (150);//setting the timer interval since timer interval is Int i am not using "
            timer1.Enabled = true;//enabling the timer
            label1.Text = "";//setting label1 text to be empty
        }
Now at last we'll go to timer_tick event so create the event first of all and we'll do some maths (*_*)
label1.Text = Type_Text.Substring(0, index_Num) + "_";//Substring is a part of Type_Text String that we declared at the start
            index_Num++;//Doing a post fix
            if (index_Num == Type_Text.Length + 1)//An if statment with a condition of course
            {
                index_Num = 0;
                
            }
Here is the full codes
        //Author : Mohamed Shimran
        //Blog : http://ultimateprogrammingtutorials.blogspot.com

        string Type_Text = "Ultimate programming tutorials";//This is the text that's going to be typed
        static int index_Num = 0;//declaring integer index_Num 

        private void Form1_Load(object sender, EventArgs e)
        {
            timer1.Interval = (150);//setting the timer interval since timer interval is Int i am not using "
            timer1.Enabled = true;//enabling the timer
            label1.Text = "";//setting label1 text to be empty
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            label1.Text = Type_Text.Substring(0, index_Num) + "_";//Substring is a part of Type_Text String that we declared at the start
            index_Num++;//Doing a post fix
            if (index_Num == Type_Text.Length + 1)//An if statment with a condition of course
            {
                index_Num = 0;
                
            }
        }

Now let's debug the program and see what happens

Typing Effect - Debug

As you can see in the image it's working nicely by the way the gif is bit laggy don't mind it . I hope this really helps .

6 comments

hi. how can i change the font size of the text "Ultimate programming tutorials" and its colr

Reply

Hello ,

just change the font size and font color from labels properties :)

Reply

Very interesting ...
I created my own typing tutorial in which I have done "error typing and then using backspace, removing that error text"..
it just looks like an animation
:)
thank U..sir
keep up the good work
,rehu

Reply

Hello, how do you stop from looping, i just want to display it one time and stop it.

Reply

Where is the toolbox for adding a label and where can I find the timer_tick event?

Reply

Did you find out how to stop the looping? Seems like nobody is answering here :(

Reply

Post a Comment

Note: Only a member of this blog may post a comment.