private void InitializeTimer()
        {
            // Call this procedure when the application starts.
            // Set to 1 second.
            timer1.Interval = 1000;
            timer1.Tick += new EventHandler(timer1_Tick);            // Enable timer.
            timer1.Enabled = true;
        }
 private void timer1_Tick(object sender, EventArgs e)
        {
            label4.Text = System.DateTime.Now.ToString("H:M");
        }
按我的设想应该是label4显示当前时间。
结果label4根本不变。
   private void label4_Click(object sender, EventArgs e)
        {
            label4.Text = System.DateTime.Now.ToString("H:M");
        }
我又写了这样一句,结果一点它就显示了。
求教哪里出问题了

解决方案 »

  1.   

    timer1.Enabled = true;就实现这个功能了吧
      

  2.   

    你在哪里调用InitializeTimer()了?
      

  3.   

    System.DateTime.Now.ToString("HH:mm:ss");
    获取时间的问题你试试这个获取时间
      

  4.   

    你在load时间中没有调用 InitializeTimer 这个方法设置time的属性,所以触发不了time的事件
      

  5.   

    你在窗体的加载事件里面调用下你写的那个时间控件,可以简便一点:label4.Text = DateTime.Now()
    在时间Tick事件里面每次加一秒就行了
      

  6.   

    没有在正确的位置调用这个Timer_Tick的事件吧
      

  7.   

    1:楼主可以在Form窗体初始化的时候或者Form的构造函数里面调用InitializeTimer()方法
    2:楼主完全也可以手动直接设置以下属性,VS会自动处理(Form2.Designer.cs)            this.timer1.Enabled = true;
                this.timer1.Interval = 1000;
                this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
      

  8.   

    到Load加上timer1.Start()试试
      

  9.   

    private void label4_Click(object sender, EventArgs e)
             {
                 label4.Text = System.DateTime.Now.ToString("H:M");
             }
    还用得着这个????