Alex Rivera | Logout

Winforms Progress bar Does Not Update (C#)

Asked 2009-07-01T11:52:48.213
16

In my program [C# + winforms]. I have progress bar & listview.

Through one method i am performing some operations & then updating data in Listview. The no of records added is the value i am setting for ProgressBar.value property. What i want here is, According to value of progress bar, it should show its progress. However the progress bar is not getting updated. Only at the end of method execution progress bar shows entire progress i.e. 100 %

Can someone help me in this regard?

Thanks, Amit

c#
Edit
Report

1 Answer

-4

The ProgressBar.Value must be between 0 and 100.

My guess is that your problem is that you're updating the ListView on the GUI thread. That means you'll need to call Application.DoEvents() after changing the ProgressBar.Value property.

It would be best to run on a BackgroundWorker and use the ProgressChanged event to handle the ProgressBar update.

Here's another question about the same topic.

answered 2009-07-01T11:56:08.957

Your Answer