0
这是非常粗糙的代码,并且我在C#上很新,而且我无法知道我的代码有什么问题。它使用一个计时器和一个进度条。我知道代码可能会更好,但有点粗糙..这是我的第一个程序的一部分,并得到了很远。使用计时器与进度条打开下一个表格
我的问题是当进度条100%使用计时器,当前房间的进度条应该隐藏,并切换到下一个房间。它可以工作,但打开隔壁房间两次?我究竟做错了什么?我希望代码在加载时最终做更多的东西,但目前不是。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void Form3_Load(object sender, EventArgs e)
{
timer1.Enabled = true;
timer1.Start();
timer1.Interval = 1000;
progressBar1.Maximum = 10;
timer1.Tick += new EventHandler(timer1_Tick);
}
private void progressBar1_Click(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
if (progressBar1.Value != 10)
{
progressBar1.Value++;
}
else
{
timer1.Stop();
this.Hide();
(new Form4()).Show();
}
}
private void progressBar1_Click_1(object sender, EventArgs e)
{
}
}
}
这将是非常好的,如果有人可以帮助我这一点的代码!这将不胜感激!
或好的做法:在订阅之前总是退订:) –
谢谢! :)这解决了我的问题;) – RevCoaster