My winform has a progress bar which should increase based on the number of files the program is processing. it works fine on one box (win xp) but not the other(winserver 2008). The bar is not filled fully by the time the process ends. Both have the same .net framework 3.5
private void data_process()
{
int progress_num = (100/checkedListBox1.Items.Count);
.......
progressBar1.Value = progressBar1.Value + progress_num;}
do you know why? and do you have better solution?
——this is the new code
private void button1_Click(object sender, EventArgs e)
{
progressBar1.Value = 0;
richTextBox1.Clear();
richTextBox1.Focus();
if (checkedListBox1.CheckedItems.Count < 1)
{
MessageBox.Show("No file is selected", "Warning");
}
else
{
if ((region != null) && (venue != null) && (lhversion != null) && (release_version != null) && (desc != null))
{
progressBar1.Maximum = checkedListBox1.Items.Count + 3;
progressBar1.Step = 1;
//progressBar1.Value = progressBar1.Value + 10;
progressBar1.PerformStep();
login();
//progressBar1.Value = progressBar1.Value + 10;
progressBar1.PerformStep();
data_process();
//progressBar1.Value = progressBar1.Value + 10;
progressBar1.PerformStep();
if (user_in == true)
{
richTextBox1.SelectionColor = Color.Blue;
richTextBox1.AppendText("Done");
}
}
private void data_process()
{
string line;
//int progress_num = (70/checkedListBox1.Items.Count);
foreach (object itemChecked in checkedListBox1.CheckedItems) // for each selected file
{
...
progressBar1.PerformStep();
}
}
I will try to use the native command to increment the progress bar without calculating the increment
(what happens when the items are > 100?)