Tutorials Navigation

Tutorials :: New :: Popular :: Top Rated

Tutorials: 18,326 Categories: 12

Total Tutorial Views: 41,412,164

C# Simple Scrolling Text Tutorial

Tutorial Name: C# Simple Scrolling Text Tutorial  

Category: PC Tutorials

Submitted By: Nissan

Date Added:

Comments: 0

Views: 5,742

Related Forum: PC Building Forum

Share:

How To Make A Simple Scrolling Text In C#.


We are going to start off by making a form and adding the following items from the tool box to your form :

1 label,
1 button,
1 timer.

Once you have them double click on your timer to get the event handler.

Now you will see some code and it will look like this :

[ Register or Signin to view external links. ]

Now put the following code into the timer :


//This Line Of Code Is To Refresh The Timer
this.Refresh();
   
   // This Line Of Code Is The Speed You want It To Scroll At.
   label1.Left += 5;
        //This If Statement Is What Makes The Label Scroll
   if (label1.Left >= this.Width)
      label1.Left = label1.Width * 1;


Now if you debug (run) your program your label will scroll if it doesn't that will be because of the timer enabled is set to false to change it to true you can use an if statement or go into the timer properties and set enabled to true i will now show you the way using a button and not using a button.

We will do the non button way first so go back to the design view and click on your timer at the bottom and you will see the properties tab on the right and this is what it looks like :

[ Register or Signin to view external links. ]

Now if you see enabled is false change it to true and debug (run) your program your label will scroll.

Ok so now we have done that way i will show you how to enable / disable the timer when you click the button so it will stop / start the label from scrolling.

Now double click on your button so you can get the event handler and put the following code into the button event handler :

if(timer1.Enabled == false)
{
   timer1.Enabled = true;
}
else
{
   timer1.Enabled = false;
}


Now debug (run) your program and when you click the button the timer will either start or stop the scrolling text.

Hope you have learned something from this tutorial

Ratings

Current rating: 3.55 by 40 users
Please take one second and rate this tutorial...

Not a Chance
1
2
3
4
5
6
7
8
9
10
Absolutely

Comments

"C# Simple Scrolling Text Tutorial" :: Login/Create an Account :: 0 comments

If you would like to post a comment please signin to your account or register for an account.