我要在窗体上面设置一个公告,公告上面的字希望是走马灯样式的.从右往左移动. 请大家指点下如何来实现.谢谢.

解决方案 »

  1.   

    int   i;   
      bool   flag   =   false;   
      private   void   button4_Click(object   sender,   System.EventArgs   e)   
      {   
      this.textBox1.Text   =   "123456789";   
      i   =   0;   
      Timer   timer   =   new   Timer();   
      timer.Tick   +=   new   EventHandler(timer_Tick);   
      timer.Interval   =   100;   
      this.textBox1.Focus();   
      this.textBox1.Select(0,1);   
      timer.Start();   
      }   
        
      private   void   timer_Tick(object   sender,   System.EventArgs   e)   
      {   
      if(this.i   ==   this.textBox1.Text.Length   )   
      {   
      this.flag   =   true;   
      }   
        
      if(this.i   ==   0   )   
      {   
      this.flag   =   false;   
      }   
        
        
      if(this.flag)   
      {   
      this.textBox1.SelectionStart   =   --i;   
      }   
      else   
      {   
      this.textBox1.SelectionStart   =   ++i;   
      }   
      }很简单,你可以试试
      

  2.   

    這TIMER是 FORMS.TIMER  還是 THREADING.TIMER?
      

  3.   

    private void Form1_Load(object sender, EventArgs e)
    {
        timer1.Enabled = true;
        timer1.Interval = 500; // 零点五秒滚动一次
    }private string strInfo = "滚动的文字       "; // 加适当的中文空格
    private int pos = 0;
    private void timer1_Tick(object sender, EventArgs e)
    {
        textBox1.Text = strInfo.Substring(pos) + strInfo.Remove(pos);
        pos = (pos + 1) % strInfo.Length;
    }