I want to be able to add some amount of progressbars into the form (the number of progressbars can vary from user to user).
I have written this code to add 1 progressbar:
ProgressBar progressbar = new System.Windows.Forms.ProgressBar();
progressbar.Name = "progressBar1";
progressbar.Size = new Size(280, 30);
progressbar.TabIndex = 9;
progressbar.Show();
flowLayoutPanel.Container.Add(progressbar);
When I run this code, I get an Exception: "Object reference not set to an instance of an object."
.
What bothers me is that both the progressbar and flowLayoutPanel aren't null when I look at them using IDE. What have I done wrong?