读书人

应用Timer控件和进度条

发布时间: 2012-08-14 10:39:57 作者: rapoo

使用Timer控件和进度条

1.拖入progressBar控件和Timer控件 2.将timer控件属性Interval改为400,Enable属性改为false并添加timer1_Tick()处理事件    private void timer1_Tick(object sender, EventArgs e)        {            if (progressBar1.Value >= 100)            {                progressBar1.Value = 0;                label1.Text = "进度" + progressBar1.Value.ToString() + "%";                return;            }            progressBar1.Value += 5;            label1.Text = "进度" + progressBar1.Value.ToString() + "%";        }3.拖入2个button控件,分别将Text属性改为”开始“和“暂停”。  双击“开始”控件,添加timer1.Enable=true;  双击“开始”控件,添加timer1.Enable=false;  4.添加label控件,修改Text属性为“0%” 


读书人网 >编程

热点推荐