You cannot use a loop to do this with a progressbar. There is a difference between running code for, while, do ... while, loops, or timers. In a loop, the code is immediately executed, and you cannot see it, in timers you can. Even if you try to set loops, if counters, this will not work:
for(int i=a;i<b;++i) { if (cnt < 1000000) { IncrProgressBar(); cnt++; } else { cnt = 0; } }
If you want to use the progressbar for this, you must put a timer in the OnTick event code that adds data to the database and in this case increases the value of progressbar. This is similar to changing the shape parameters of other properties (Text, Size, ...). If you want to see changes on a component, you must use timers.
source share