B
B
bqio2019-10-10 07:19:51
C++ / C#
bqio, 2019-10-10 07:19:51

Why is the ProgressBar not updating?

mainform:

public void AnalysisData()
{
  ProgressForm PF = new ProgressForm();
  PF.ShowDialog(this);
  PF.UpdateProgress(50);
}

ProgressBarForm Method:
public void UpdateProgress(int value)
{
  Progress.Value = value;
}

When the form appeared, progress remained at 0% as it was. What's wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2019-10-10
@xpert13

ShowDialog stops further code execution until the form is closed. You need to update the progressbar first and then display the form:

public void AnalysisData()
{
  ProgressForm PF = new ProgressForm();
  PF.UpdateProgress(50);
  PF.ShowDialog(this);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question