Winforms Progress bar Does Not Update (C#)

前端 未结 4 1960
青春惊慌失措
青春惊慌失措 2020-12-03 07:57

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 o

4条回答
  •  一向
    一向 (楼主)
    2020-12-03 08:31

    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.

提交回复
热议问题