Click here to Skip to main content
15,917,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Is there any posibility to use progress bar...in this example....
When I click button that will e.x sort data ok the sort code is ok and it works. but before sorted first to go a progress bar than in listbox to be data sorted....!

so only code for progress bar...
Posted
Comments
Nelek 22-Apr-12 18:45pm    
Would you like to use "improve question" and rewrite what you want a bit more clear? I don't know the others, but I can not understand what you want

There are 2 ways to use a progress bar:

One is to manage it yourself performing steps when you want the bar to increase:

C#
progressBar1.PerformStep();


Using this you will need to calculate the number of steps you want and when you want them to show in the code. so if you have 2 steps you will set the progresbar to have 3 steps and after each step call the code above.

The second way is to use a timer. Here you set the timer interval to whatever time you want your step to move and call the perform step on the timer.tick event. When you start your process you also start the timer to enable the progressbar. On load the timer needs to be disabled and you will have something like this:

C#
timer1.enabled=true;
//put your procedure here
timer1.enabled=false
//to stop the progress bar when the procedure has completed
 
Share this answer
 
Comments
h7h7h7 22-Apr-12 19:08pm    
thnx it work but with a small problem... the code is this :

progressBar1.Minimum = 0;
progressBar1.Maximum = 100;
progressBar1.Value = 70;
progressBar1.PerformStep();
timer1.Enabled = true;

List.Sort();
listBox1.DataSource = List;

what should I change, if I want first to be filled progress bar, and after that in listbox1 to see data sorted...... and not in the same time I click button and data are in listbox during the progress bar is filling
thnx it work but with a small problem... the code is this :

progressBar1.Minimum = 0;
progressBar1.Maximum = 100;
progressBar1.Value = 70;
progressBar1.PerformStep();
timer1.Enabled = true;

List.Sort();
listBox1.DataSource = List;

what should I change, if I want first to be filled progress bar, and after that in listbox1 to see data sorted...... and not in the same time I click button and data are in listbox during the progress bar is filling
 
Share this answer
 
Comments
milenalukic 22-Apr-12 20:22pm    
I'm not sure I understand you. Do you want your progress bar to be completey filled before showing the list?

If so you need:

progressbar1.minimum=0;
progressbar1.maximum=100;
timer1.enabled=true;

List.Sort();
timer1.enabled=false;
Progressbar1.value=100;
listbox1.datasource=list

timer1_tick()
{
progressbar1.performstep();
}


This will start your progressbar from 0, then when the sort is complete will show a full progressbar and then show the listbox.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900