RE: Using Progress Bar
From: pradeep_TP (pradeepTP_at_discussions.microsoft.com)
Date: 03/21/05
- Next message: Morten Wennevik: "Re: decimal - int"
- Previous message: Ajay Kalra: "Re: create plugin assemblies?"
- In reply to: Raed Sawalha: "Using Progress Bar"
- Next in thread: Ignacio Machin \( .NET/ C# MVP \): "Re: Using Progress Bar"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 21 Mar 2005 06:23:06 -0800
Hi raed,
I have a neat trick which can be used in this scenario. I am not sure
whether i am fully correct saying this because there may be other ways of
doing this. But this is how i have done.
I have created a Timer control with Interval Property set to 1000 and
Enalbled property set to TRUE.
The idea is to increment the progress bar in the timer control while your
component does the work of doint its task. Once the task is complete you can
disable the timer and then hide the progress bar. I have modifed your code
accordingly as below.
private void btnProcess_Click(object sender, System.EventArgs e)
{
btnProcess.Enabled = false;
MailBoxRenamer oMailBox = new MailBoxRenamer();
//How Can i make the progress bar moving while rename processing is
underway
pBarCtrl.Visible = true;
//enable timer
timer1.Enabled = true;
oMailBox.RenameAll();
MessageBox.Show("Operation Successfully Completed","Operation
Done",MessageBoxButtons.OK,MessageBoxIcon.Information);
btnProcess.Enabled = true;
//disable timer
timer1.Enabled = false;
//hide progress bar
pBarCtrl.Visible = true;
}
Now write the following int teh Tick event of the timer
private void timer1_Tick(object sender, System.EventArgs e)
{
//Incrementing the value by 10. You can also set to lower value to cause
more delay
progressBar1.Value += 10;
}
However you have to be careful about the interval that you set for the
timer. If the interval is not set properly then you might see that the
progress bar has reached its end before finishing its task. so set teh
interval accordingly.
Hope this helps.
Happy Programming!!
Pradeep_TP
"Raed Sawalha" wrote:
> Dear, I have windows form , the form is using a class to do all tasks needed
> like this
> private void btnProcess_Click(object sender, System.EventArgs e)
> {
> btnProcess.Enabled = false;
> MailBoxRenamer oMailBox = new MailBoxRenamer();
> //How Can i make the progress bar moving while rename processing is
> underway
> pBarCtrl.Visible = true;
> oMailBox.RenameAll();
> MessageBox.Show("Operation Successfully Completed","Operation
> Done",MessageBoxButtons.OK,MessageBoxIcon.Information);
> btnProcess.Enabled = true;
> }
>
> oMailBox is object of MailBoxRenamer class that do following:
>
> 1. Get All Files in Specified Directory
> 2. Get the Name Of each folder and query the database about its relative ID
> 3. Rename the folder from the name to ID
>
> All I need how to enable dynamic progress action during renaming
- Next message: Morten Wennevik: "Re: decimal - int"
- Previous message: Ajay Kalra: "Re: create plugin assemblies?"
- In reply to: Raed Sawalha: "Using Progress Bar"
- Next in thread: Ignacio Machin \( .NET/ C# MVP \): "Re: Using Progress Bar"
- Messages sorted by: [ date ] [ thread ]