Click here to Skip to main content
11,704,001 members (67,400 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
how to auto move a label left to right in c# windows Form programming
Posted 16-Jul-12 20:09pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Use timer control and increment the label left position in each timer interval until it reaches the right end.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I took a very crude approach to do this:

1. I added the label on the form.
2. added a timer on the form.
3. set the timer timeout to 100ms.
4. added the following code to the form

public Form1()
        {
            InitializeComponent();
            timer1.Start();
        }
 
        private void timer1_Tick(object sender, EventArgs e)
        {
            label1.Location = new Point(label1.Location.X + 5, label1.Location.Y);
 
            if(label1.Location.X  > this.Width)
            {
                label1.Location = new Point(0 - label1.Width, label1.Location.Y);
            }
        }

This gave me a scrolling left to right. also it reappears on left once it goes out of form on right side.

Try it and see if you could get this to work.
  Permalink  
Comments
sandeep nagabhairava at 17-Jul-12 7:39am
   
nice job rahul... my 5!
Member 11706275 at 21-May-15 21:55pm
   
hai how to move the label from middle to right corner.pls any one help me its urjent.
Improve
Bhavesh Patel at 28-May-15 2:44am
   
Thank you...good job.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

private void timer1_Tick(object sender, EventArgs e)
{
    label1.Left = label1.Left + 10;
}
 
private void Form1_Load(object sender, EventArgs e)
{
    timer1.Enabled = true;
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

hi narazalok,

please go through below link that gives u idea for scrolling using jquery.

http://stackoverflow.com/questions/5988803/right-to-left-scrolling-text-effect[^]
  Permalink  
Comments
Rahul Rajat Singh at 17-Jul-12 3:55am
   
I think the OP wants it for windows forms and not for web application.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

hai how to move the label from middle to right corner.pls any one help me its urjent.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

hi
i change the code to the label go on Y row and added a pause option if you click the label

//your trigger :timer1.Start();
private void timer1_Tick(object sender, EventArgs e)
{
    label2.Text ="BLAH BLAH BLAH BLAH";
    label2.Location = new Point(label2.Location.X, label2.Location.Y-2);
 
    if (label2.Location.Y < 0)
    {
        label2.Location = new Point(label2.Location.X, 255);
    }
}
 
private void label2_Click(object sender, EventArgs e)
{
    if (timer1.Enabled)
    {
        timer1.Stop();
    }
    else { timer1.Start(); }</pre>
  Permalink  

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

  Print Answers RSS
0 Maciej Los 530
1 OriginalGriff 510
2 Sergey Alexandrovich Kryukov 421
3 Andy Lanng 294
4 F-ES Sitecore 220
0 OriginalGriff 8,744
1 Sergey Alexandrovich Kryukov 7,747
2 CPallini 5,107
3 Maciej Los 4,716
4 Mika Wendelius 3,606


Advertise | Privacy | Mobile
Web02 | 2.8.150819.1 | Last Updated 21 May 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100