Click here to Skip to main content
15,920,633 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Everyone,

I want to scroll the label from top to bottom and from bottom to top , Now i am using one code by using this i can scroll from left to right , can any one suggest me please .

I am giving code also
C#
private void timer1_Tick(object sender, EventArgs e)
{
    label2.Location = new Point(label2.Location.X + 5, label2.Location.Y);

    if (label2.Location.X > this.Width)
    {
        label2.Location = new Point(0 - label2.Width, label2.Location.Y);
    }
}
Posted
Updated 30-May-13 22:16pm
v2
Comments
Osman24 31-May-13 3:43am    
When you say "I want to scroll the label from top to bottom and from bottom to top", did you mean that I want scroll label from top to bottom pixel by pixel and when it reaches the bottom I want scroll it to the top pixel by pixel again ?

Just like your code alters the horizontal components (X) of Location and hence gernerates horizontal movement, change the vertical component (Y) to move vertically.
C#
// Do so:
label2.Location = new Point(fixed, changing);
//Instead of
label2.Location = new Point(changing, fixed);
 
Share this answer
 
C#
private void timer1_Tick(object sender, EventArgs e)
{
    label2.Location = new Point(label2.Location.X, label2.Location.Y + 5);

    if (label2.Location.Y > this.Height)
    {
        //label2.Location = new Point(0 - label2.Width, label2.Location.X);
        //label2.Location = new Point(changing, fixed);
        label2.Location = new Point( label2.Location.X,0 - label2.Height);
    }
}


Just use this code for scrolling the labels from top to bottom
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900