i have used progress bar in my application..my application is working fine but the progress bar is blank..it does not show the working progress what is wrong??
问题:
回答1:
Probably you are performing the work in the main GUI thread. This causes all GUI events to be delayed until the task is finished.
Use a BackgroundWorker instead and use its ProgressChanged event to update the progress bar.
Also remember to set WorkerReportsProgress to true
on your background worker.
回答2:
Refer this question of StackOverflow:
Updating DataGrid From a BackGroundWorker
I am assuming you must be accessing UI object using Invoke method.
If not try using following approach (Executes the specified delegate, on the thread that owns the control's underlying window handle, with the specified list of arguments.):
//In Form.Designer.cs ProgressBar progressBar= new ProgressBar ();
//In code behind under Background worker method ProgressVlaueSetter SetProgressValueDel = SetProgressValue;
if (progressBar.InvokeRequired) {
progressBar.Invoke(SetProgressValueDel , 20); }
private delegate void ProgressVlaueSetter (intvalue);
//Set method invoked by background thread private void SetProgressValue(intvalue) { progressBar.Value= value; }
回答3:
A compatible operating system and environment are prerequisites for a progress bar to work because the method of drawing the extending bar or blocks on the computer display is not compatible across all platforms. The progress bar type is protected and regulated and may be licensable but would not operate everywhere in a nation, state, province or even a city unless a specific type of progress indication is lawful. Moving code or an application to a different computer type or host system can be plagued with similar issues for other features.