当前位置: 编程技术>.net/c#/asp.net
c#进度条ProgressBar学习笔记
来源: 互联网 发布时间:2014-08-30
本文导语: 对于进度条,无碍乎是最小最大值,以及当前值等一些重要的属性,至于方法,用得较多的是PerformStep()和PerformClick()之类的。 代码如下,没有注释,大家凑和看吧。 private void btnRun_Click(object sender, EventArgs e) { btnRun.Enabled...
对于进度条,无碍乎是最小最大值,以及当前值等一些重要的属性,至于方法,用得较多的是PerformStep()和PerformClick()之类的。
代码如下,没有注释,大家凑和看吧。
private void btnRun_Click(object sender, EventArgs e)
{
btnRun.Enabled = false;
if (txtBoxTarget.Text.Equals(String.Empty) || txtBoxTimes.Text.Equals(String.Empty))
{
MessageBox.Show("请输入连接的URL和连接次数!", "提示",
MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
int length = Int32.Parse(txtBoxTimes.Text.Trim());
string url = txtBoxTarget.Text.Trim();
double process = 0;
int show = 0;
DateTime rightNow = DateTime.Now;
DateTime end;
TimeSpan interval;
toolStripStatusLabel.Text = "连接中";
progressBar.Visible = true;
progressBar.Minimum = 0;
progressBar.Maximum = length;
for (int i = 1; i