I have a application in which I use a process bar which starts after I click Start button (Start button is disabled after I click ) and once the process is complete the start button is enabled.
when I click start again there are 2 process bars I just want one process bar every time I re- execute
button1.Enabled = false;
pBar = new ProgressBar(); // now assigning to field
Controls.Add(pBar);
pBar.Name = "ProgresBar1";
pBar.Dock = DockStyle.Bottom;
pBar.Style = ProgressBarStyle.Marquee;
pBar.MarqueeAnimationSpeed = 10;
pBar.Width = 100;
pBar.Height = 30;
pBar.Minimum = 0;
pBar.Maximum = 100;
pBar.Value = 100;
//-------------------------------------------------
System.Threading.Thread.Sleep(10000);
//--------Statements----------------------------------------
//------------------------------------------------
pBar.Style = ProgressBarStyle.Continuous;
pBar.MarqueeAnimationSpeed = 5;
button1.Enabled = true;
3 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.

VulpesPosted Aug 11, 2014, 6:33 AM
Initially, you could set the Visible property to false and, when you want to use it, set it to true and also set the Style and MarqueeAnimationSpeed properties to their initial values.
Farhan ShariffPosted Aug 11, 2014, 6:59 AM
VulpesPosted Aug 11, 2014, 6:10 AM
if (pBar != null) Controls.Remove(pBar);