标题:简单进度条代码和计时器代码
只看楼主
泥泥
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-11-20
得分:0 
这是我写的,但是我无法在开始按钮中控制时间的走动,麻烦前辈帮忙解决一下,谢谢!
    long second = 360;
        //时钟控件
        private void Changetimer_Tick(object sender, EventArgs e)
        {
            second -= 1;
            lblminute.Text = new DateTime(second * 10000000).ToLongTimeString();
            //进度条根据时间的变化而变化
            if (prggessbar.Value >= 360)
            {
                Changetimer.Enabled = false;
                //..关闭或开启程序
            }
            else
            {
                prggessbar.Value += 1;
            }
        }

        //结束按钮
        private void btnEndTime_Click(object sender, EventArgs e)
        {
            //如何正在计时,则先停止再清零,否则直接清零
            //if (this.Changetimer.Enabled == true)
            //{
                long second = 360;
                lblminute.Text = new DateTime(second * 10000000).ToLongTimeString();

                prggessbar.Value = 0;//设置当前值

                Changetimer.Enabled = false;
            //}
        }
        //开始按钮
        private void btnBeginTime_Click(object sender, EventArgs e)
        {
            if (this.Changetimer.Enabled == true)
            {
                Changetimer.Enabled = true;
                //进度条的加载
                prggessbar.Minimum = 0;
                prggessbar.Maximum = 360;
                prggessbar.Step = 1;
            }
            else
            {
                Changetimer.Enabled = false;
                Changetimer.Interval = 1000;//一秒中加载一次
                Changetimer.Tick += new EventHandler(this.Changetimer_Tick);
            }
        }
2012-11-20 01:44
hui臭小子
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2014-10-15
得分:0 
回复 楼主 zyz0304360
代码哪里去啊亲  我也想要
2014-10-15 10:00



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-202947-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.215757 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved