Click here to Skip to main content
16,011,988 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hai all,
I create a windows application program, it have some crystal reports. crystal reports take 2 to 10 seconds to display because a 'loop program' work to take data from the database. I want to place a progress bar in this time. How to calculate the time taken by the 'loop program' and set 'the progress bar values'. I am the new one in this.
Thanks in advance
Madhukumar Viswanath
Posted
Updated 27-May-12 6:49am
v2

It's quite impossible to calculate the time the report is going to take. For this reason I'd suggest using a Marquee style progress bar to indicate that the operation is going on but the length is indeterminate.
 
Share this answer
 
Comments
Madhukuamr V 27-May-12 10:41am    
Sir What is the Marquee style progress bar, please give more details
ZaiDz 27-May-12 17:35pm    
progressBar1.Style = ProgressBarStyle.Marquee;
Wendelius 1-Jun-12 0:40am    
Thanks for the update.
Sergey Alexandrovich Kryukov 28-May-12 2:04am    
Agree, a 5.
--SA
Wendelius 1-Jun-12 0:39am    
Thanks :)
Marquee style progress bar is like the progress bar when you open your solution in visual studio.A green light travel through the bar but no figure is shown.
 
Share this answer
 
C#
private void button1_Click(object sender, EventArgs e)
       {
           int Maxitem = 0;
           Maxitem = 50000;
           progressBar1.Maximum = 50000; // your loop max no. 
           progressBar1.Value = 0;

           for (int i = 0; i < Maxitem; i++)
               progressBar1.Value += 1;


           MessageBox.Show("completed");
           progressBar1.Value = 0;
       }


if you know maximum number of your loop program than in this loop you will place your progess bar.
 
Share this answer
 
Comments
Madhukuamr V 28-May-12 14:03pm    
Useful answer. thanks
C#
for(int i = 0;i < 234;i++)
{
float Percent = (float)i / 234.0f;
}
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 28-May-12 2:05am    
Even a joke needs better code...
--SA
ZaiDz 28-May-12 17:09pm    
I don't understand what is so bad about it.

Sergey Alexandrovich Kryukov 28-May-12 19:55pm    
Well, '234' is repeated. Do I have to explain why it's bad?
--SA
ZaiDz 29-May-12 15:29pm    
Yes you do, I was just showing the OP how to get the percentage of a loop.
It's supposed to be simple.

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