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;


VulpesRank #55 · 29.2K reputationPosted Aug 11, 2014, 2:33 AM EDT
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.
VulpesRank #55 · 29.2K reputationPosted Aug 11, 2014, 2:10 AM EDT
if (pBar != null) Controls.Remove(pBar);
Farhan ShariffRank #2,004 · 725 reputationPosted Aug 11, 2014, 2:59 AM EDT