功能:比如3个button,起初button的颜色是white,定时器记时5秒,5秒后button1的颜色变成red,之后定时器再次计时,5秒后第二个button也变成红色,依次下去3.4.5或者更多。求指教!!!!!谢谢~

解决方案 »

  1.   


            Timer timer = new Timer();
            List<Button> btns;
            int i = 0;        public Form2()
            {
                InitializeComponent();
               
                btns = new List<Button>();
                foreach (Control con in this.Controls)
                {
                    if (con is Button)
                    {
                        btns.Add(con as Button);
                    }
                }
                i = btns.Count;
                timer.Interval = 5000;
                timer.Tick += new EventHandler(timer_Tick);
                timer.Start();
                
            }        void timer_Tick(object sender, EventArgs e)
            {
                //throw new NotImplementedException();            btns[i - 1].ForeColor = Color.Red;
                i--;
            }
      

  2.   

    为什么我执行不了?执行就第一个button改了颜色 能给我发份源代码么?[email protected] 谢谢哦 
      

  3.   

    非常感谢!第一次用CSDN,不知道怎么给你分哈!
      

  4.   

    想问下我的button放在group控件里,我能不能只查询指定控件里button呀?不知道怎么实现谢谢