一个进度条的简单的问题

ybnc 2014-01-20 08:43:54
做个最简单的TIMER控制的进度条,结果不动弹,帮忙看看哪里的问题?谢谢

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
progressBar1.Value = 0;
}

private void button1_Click(object sender, EventArgs e)
{
timer1.Interval = 100;
timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
if (progressBar1.Value >= 100)
progressBar1.Value = 0;
else progressBar1.Value = progressBar1.Value + 10;

}
}
}
...全文
164 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
智商余额不足 2014-01-20
  • 打赏
  • 举报
回复
引用 6 楼 u013520911 的回复:
[quote=引用 4 楼 hwenycocodq520 的回复:] 请问你button1绑定button1_Click了没?
[/quote] ok的,刚复制你的代码在我这里都运行得了,仔细检查吧
ybnc 2014-01-20
  • 打赏
  • 举报
回复
引用 4 楼 hwenycocodq520 的回复:
请问你button1绑定button1_Click了没?

BenBenBears 2014-01-20
  • 打赏
  • 举报
回复
试一下另一个button。
智商余额不足 2014-01-20
  • 打赏
  • 举报
回复
请问你button1绑定button1_Click了没?
ybnc 2014-01-20
  • 打赏
  • 举报
回复
引用 1 楼 BenBenBears 的回复:


        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Interval = 100;
            timer1.Enabled = true;
            timer1.Start();
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (progressBar1.Value >= 100)
                progressBar1.Value = 0;
            else progressBar1.Value = progressBar1.Value + 10;
             Application.DoEvents();
        }
还是不动弹
kxyzjm62 2014-01-20
  • 打赏
  • 举报
回复
没有什么问题
BenBenBears 2014-01-20
  • 打赏
  • 举报
回复


        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Interval = 100;
            timer1.Enabled = true;
            timer1.Start();
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (progressBar1.Value >= 100)
                progressBar1.Value = 0;
            else progressBar1.Value = progressBar1.Value + 10;
             Application.DoEvents();
        }
ybnc 2014-01-20
  • 打赏
  • 举报
回复
引用 12 楼 huang369509940 的回复:
[quote=引用 10 楼 huang369509940 的回复:] [quote=引用 9 楼 u013520911 的回复:] designer.cs里面增加
// timer1
            // 
            this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
就可以了,这是个什么情况?
这是你没加委托啊,Timer里的事件没写上吧[/quote] 有这个的话就不用加那句话了[/quote] 确实是这里的问题。多谢!
黄大仙儿 2014-01-20
  • 打赏
  • 举报
回复
引用 10 楼 huang369509940 的回复:
[quote=引用 9 楼 u013520911 的回复:]
designer.cs里面增加
// timer1
//
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);

就可以了,这是个什么情况?

这是你没加委托啊,Timer里的事件没写上吧[/quote]

有这个的话就不用加那句话了
BenBenBears 2014-01-20
  • 打赏
  • 举报
回复
引用 9 楼 u013520911 的回复:
designer.cs里面增加
// timer1
            // 
            this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
就可以了,这是个什么情况?
注册事件。
黄大仙儿 2014-01-20
  • 打赏
  • 举报
回复
引用 9 楼 u013520911 的回复:
designer.cs里面增加
// timer1
            // 
            this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
就可以了,这是个什么情况?
这是你没加委托啊,Timer里的事件没写上吧
ybnc 2014-01-20
  • 打赏
  • 举报
回复
designer.cs里面增加
// timer1
            // 
            this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
就可以了,这是个什么情况?

111,093

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧