Progress bar doesn't increment

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I created a windows form that has a progress bar on it. I am running a bunch of statements to update data on the database. I want the progress bar to increment (perform one step) after each update. The problem is that the progress bar doesn't move (it just sits there until the end) can anyone give me an example of how to accomplish this?

example:
progressBar1.Visible=true;
progressBar1.Show();
progressBar1.Maximum = 24;
progressBar1.Step = 1;
progressBar1.PerformStep();
Perform_update1;
progressBar1.PerformStep();
Perform_update2;
progressBar1.PerformStep();
Perform_update3;
etc.

thanks in advance

-Jeff-
 
Jeff said:
I created a windows form that has a progress bar on it. I am running a bunch
of statements to update data on the database. I want the progress bar to
increment (perform one step) after each update. The problem is that the progress
bar doesn't move (it just sits there until the end) can anyone give me an example
of how to accomplish this?
example:
progressBar1.Visible=true;
progressBar1.Show();
progressBar1.Maximum = 24;
progressBar1.Step = 1;
progressBar1.PerformStep();
----------- Application.DoEvents();
Perform_update1;
progressBar1.PerformStep();
----------- Application.DoEvents();
Perform_update2;
progressBar1.PerformStep();
----------- Application.DoEvents();
Perform_update3;
etc.

thanks in advance

-Jeff-


Hope that helps.

Mythran
 
You may want to trap RowUpdating/RowUpdated for each Adapter you are calling
update on. Right before you call update, set the Maximum value of the
progress bar to that datatables.Rows.Count, then increment it on either
Updating or Updated. After the update, reset it to 0 (the value) then reset
the Maximum to the next table's Rows.Count.

--
W.G. Ryan MVP Windows - Embedded

http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/
Jeff said:
I created a windows form that has a progress bar on it. I am running a
bunch of statements to update data on the database. I want the progress bar
to increment (perform one step) after each update. The problem is that the
progress bar doesn't move (it just sits there until the end) can anyone give
me an example of how to accomplish this?
 
Actually your whole app will seam frozen as you are performing step after
step sequentially. To up the progress bar (and also for the window to
process any other messages like move, close, etc), call
Application.DoEvents(); call after each increment.

Jeff said:
I created a windows form that has a progress bar on it. I am running a
bunch of statements to update data on the database. I want the progress bar
to increment (perform one step) after each update. The problem is that the
progress bar doesn't move (it just sits there until the end) can anyone give
me an example of how to accomplish this?
 
Back
Top