我在C#中編寫了一個表單,在其中您在NumericUpDown框中輸入一個值,並且在進度條下單擊該按鈕時將增加輸入的值。ProgressBar按照NumericUpDown框中的值增加
我使用的計時器對於本與代碼之中:
private void ProgressBar_Tick(object sender, EventArgs e)
{
if (filesize <= 60)
sixtyfree.Increment(filesize);
}
文件大小是的NumericUpDown框的名稱,我這個值轉換爲int,使得其將與這個工作。我面對的問題是,無論60歲以下我輸入什麼數字,都會填滿進度條,而不是隻輸入「文件大小」中輸入的數量,任何人都可以幫我解決這個問題嗎?
呀ofcourse,這裏是我的全碼:
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 Worst_fit_algorithm_GUI
{
public partial class Form1 : Form
{
int filesize;
int progressBarSetValue = 40; //The set value of first progressBar
public Form1()
{
InitializeComponent();
}
private void downloadfile_Click(object sender, EventArgs e)
{
this.ProgressBar.Start();
}
private void ProgressBar_Tick(object sender, EventArgs e)
{
if (sixtyfree.Value <= sixtyfree.Maximum - progressBarSetValue)
{
sixtyfree.Value = progressBarSetValue + (int)filesize;
ProgressBar.Stop();
}
}
private void FileSize_ValueChanged_1(object sender, EventArgs e)
{
filesize = Convert.ToInt32(FileSize.Value);
}
private void sixtyfree_Click(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
}
}
什麼進度的最大價值?絕對是60左右吧? – 2015-02-24 19:02:36
它有40設定值已經和最大值爲100,我想輸入的號碼時就加入到這個40 – Max 2015-02-24 20:58:31
sixtyfree看起來像NumericUpDown控件。如果文件大小不會改變,那麼進度條將始終增加,直到達到最大值。我認爲* *你想要的東西像'如果(sixtyfree.Value +文件大小<= 60)' – LarsTech 2015-02-24 21:07:25