Click here to Skip to main content
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 21: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!
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 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 OriginalGriff 505
1 Maciej Los 325
2 Richard MacCutchan 265
3 Mathew Soji 220
4 BillWoodruff 210
0 OriginalGriff 8,804
1 Sergey Alexandrovich Kryukov 7,457
2 DamithSL 5,689
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web03 | 2.8.1411028.1 | Last Updated 26 Sep 2013
Copyright © CodeProject, 1999-2014
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