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-
Mythran - 15 Jun 2004 00:39 GMT
> 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
William Ryan eMVP - 15 Jun 2004 03:37 GMT
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.

Signature
W.G. Ryan MVP Windows - Embedded
http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/
> 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;
[quoted text clipped - 12 lines]
>
> -Jeff-
Chris Botha - 15 Jun 2004 04:20 GMT
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.
> 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;
[quoted text clipped - 12 lines]
>
> -Jeff-