做项目的时候  我想用一个lable控件作出一个从左向右的滚动效果,当它到了最左边的时候又会自动的回到右边 然后就是一直的滚动 从右边到左边一直循环这滚动  请问一下  我该怎么样去做它   
还忘各位不吝赐教....     谢谢了 (最好能给点代码的提示)

解决方案 »

  1.   


    private void Form1_Load(object sender, EventArgs e)
            {
                this.label1.Location = new Point(0, 0);
            }
             int xPox = 0;
            bool ist = true;
            private void timer1_Tick(object sender, EventArgs e)
            {
                this.label1.Location = new Point(xPox,this.label1.Location.Y);            if (xPox == this.Width-this.label1.Size.Width)
                    ist = false;
                if(xPox==0)
                    ist = true;
                if (ist)
                    xPox++;
                else
                    xPox--;
            }
      

  2.   

    这个小功能如何实现?[label上的文字从右往左滚动显示]
    http://topic.csdn.net/u/20090606/10/5fc58b85-d448-4449-a46e-feb3fd9b0bcc.html你稍微改一下就行了 
      

  3.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Threading;namespace WindowsApplication37
    {
        public partial class Form1 : Form
        {
            Button B = new Button();
            Button B2 = new Button();
            Marquee M = null;        public Form1()
            {
                InitializeComponent();            B.Parent = this;
                B.Text = "开始";
                B.Click += new EventHandler(B_Click);
                B2.Parent = this;
                B2.Text = "停止";
                B2.Click += new EventHandler(B2_Click);
                B2.Location = Point.Add(B.Location, new Size(B.Width, 0));
            }        void B_Click(object sender, EventArgs e)
            {
                M = new Marquee();
                M.Start(this, "ABCDEFG", Point.Add(B.Location, new Size(0, B.Height)), new Size(100, 50));
            }        void B2_Click(object sender, EventArgs e)
            {
                M.Stop();
                M = null;
            }
        }    class Marquee
        {
            PictureBox PB = new PictureBox();
            int X = 0;
            String DrawText = String.Empty;
            Bitmap OrgBmp = null;
            delegate void SetImage(Image NewImage);        public void Start(Form Parent, String Text, Point Location, Size RectSize)
            {
                this.DrawText = Text;
                PB.Parent = Parent;
                PB.Location = Location;
                PB.Size = RectSize;
                X = RectSize.Width;
                PB.Visible = true;
                PB.Image = new Bitmap(PB.ClientRectangle.Width, PB.ClientRectangle.Height);
                Graphics G = Graphics.FromImage(PB.Image);
                G.FillRectangle(new SolidBrush(PB.BackColor), PB.ClientRectangle);
                G.Dispose();
                OrgBmp = new Bitmap(PB.Image);
                Thread T = new Thread(new ThreadStart(DoDraw));
                T.Start();
            }        public void Stop()
            {
                PB.Visible = false;
            }        void DoDraw()
            {
                while (PB.Visible)
                {
                    Bitmap CacheBmp = new Bitmap(OrgBmp);
                    Graphics G = Graphics.FromImage(CacheBmp);
                    G.DrawString(DrawText, new Font("宋体", 10), new SolidBrush(Color.Black),
                        new PointF(X = X-- < -G.MeasureString(this.DrawText, new Font("宋体", 10)).Width ? PB.Size.Width : X, 0));
                    G.Dispose();
                    PB.Invoke(new SetImage(DoSetImage), new Object[] { CacheBmp });
                    Thread.Sleep(30);
                }
            }        void DoSetImage(Image NewImage)
            {
                PB.Image = NewImage;
            }
        }
    }
      

  4.   

    bool ist = true;//为true时字幕向右走,反之向左走 
           private void timer1_Tick(object sender, EventArgs e)
            {
                this.label1.Location = new Point(xPox,this.label1.Location.Y);            if (xPox == this.Width-this.label1.Size.Width)//字幕到了最右边
                    ist = false;
                if(xPox==0)//字幕到了最左边
                    ist = true;
                if (ist)
                    xPox++;//右走
                else
                    xPox--;//左走
            }
      

  5.   

    一楼的似乎实现不了的……
    试试这个:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;namespace 欢迎条
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void Form1_Load(object sender, EventArgs e)
            {
                this.timer1.Interval = 10;
                this.timer1.Enabled = true;
                //this.WindowState = FormWindowState.Maximized;
            }
            private void timer1_Tick(object sender, EventArgs e)
            {
                label1.Left = label1.Left - 2;
                if (label1.Right<0) 
                {
                    label1.Left = this.Width;
                }
            }        private void button1_Click(object sender, EventArgs e)
            {
                this.Close();
            }
        }
    }
      

  6.   

    抱歉了,一楼的是可以的,实现的是字体向左向右移动的public partial class Form1 : Form
        
        {        public Form1()
            
            {            InitializeComponent();
            
            }
            private void Form1_Load(object sender, EventArgs e)        {            this.timer1.Interval = 1;            this.timer1.Enabled = true;            //this.WindowState = FormWindowState.Maximized;        }        bool i = true;        int xPox;        private void timer1_Tick(object sender, EventArgs e)        {            this.label1.Location = new Point(xPox, this.label1.Location.Y);            if (xPox > this.Width - this.label1.Size.Width+label1.Width)//字幕到了最右边
                           i = false;            if (xPox < 0-label1.Width)//字幕到了最左边                i = true;            if (i)                xPox+=5;//右走            else                xPox-=5;//左走
            }        private void label1_Click(object sender, EventArgs e)        {            this.Close();        }    }
      

  7.   

    LBG.Text = LBG.Text.Substring(1) + LBG.Text[0];
    这个是最好用的
    LBG是标签
    不明白的找我
    还有啊,别忘记TMG.Stop();启动记时器
      

  8.   

                label1.Left = label1.Left - 2;
                if (label1.Right < 0)
                {
                    label1.Left = this.Width;
                }