user2053912
user2053912

Reputation: 203

Progress Bar not Visible

If I create a ProgressBar via the ToolBox and add the following line in my code:

progressBar1.value = 40;

I am able to view the progress bar when my application runs.

However, if I try to create one via my code, I am unable to view one - The progress bar is not visible. Here is my code:

ProgressBar progressBar1 = new ProgressBar();
progressBar1.Location = new System.Drawing.Point(168, 180);
progressBar1.Height = 650;
progressBar1.Width = 340;            
progressBar1.Minimum = 20;
progressBar1.Maximum = 100;            
progressBar1.Value = 49;    
progressBar1.Visible = true;

Upvotes: 0

Views: 2214

Answers (2)

Leon Lucardie
Leon Lucardie

Reputation: 9730

You need to add the progressbar to your application window first.

Assuming you're using WPF creating the ProgressBar in your Window class:

this.Children.Add(progressBar1);

Upvotes: 1

Farhad Jabiyev
Farhad Jabiyev

Reputation: 26635

If you are using Windows Forms then you must add it to your form like that:

this.Controls.Add(progressBar1);

If you are using WPF then you must do that:

this.Children.Add(progressBar1);

Upvotes: 4

Related Questions