设一个button,点一下开始事件,事件有个timer过程,在点一下结束事件时 timer 控价结束

解决方案 »

  1.   

    设置一个全局的timer  去控制
      

  2.   

    timer.Enabled=!timer.Enabled
      

  3.   

    可以写个简单的,给我看看吗?我不知道timer.enabled=!timer.enabled放在哪里?
    如果用if(),括号里面写什么好……呜呜呜
      

  4.   


    namespace 按钮互斥
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            bool star = false;
            private void button1_Click(object sender, EventArgs e)
            {
                star = !star;
                if (star)
                {
                    this.timer1.Interval = 500;
                    this.timer1.Enabled = true;
                    this.button1.Text = "停止获取当前时间";
                }
                else
                {
                    this.timer1.Enabled = false;
                    this.button1.Text = "获取当前时间";
                }
                            }        private void timer1_Tick(object sender, EventArgs e)
            {
                this.label1.Text = DateTime.Now.ToString();
               
            }
        }
    }
      

  5.   

    stopwatch有个Running的属性