aronmatthew
Active member
- Joined
- Aug 5, 2019
- Messages
- 41
- Programming Experience
- Beginner
I'm having a problem with a from constructor that in some cases is taking a while to put together. Here is the block of code that is causing a delay.
I would like to show a progress bar while this block of code is loading within a form constructor. I not sure where to place the background worker to use with a progress bar in this case.
delay block:
foreach(string file in overwriteList)
{
fileCheckBox = new CheckBox();
fileCheckBox.Left = selectAllButton.Left+5;
fileCheckBox.AutoSize = true;
if (previous == null)
fileCheckBox.Top = selectAllButton.Bottom;
else
fileCheckBox.Top = previous.Bottom;
fileCheckBox.Tag = file;
this.Controls.Add(fileCheckBox);
fileLabel = new Label();
fileLabel.Top = fileCheckBox.Top;
fileLabel.Left = fileCheckBox.Right + 5;
fileLabel.Text = file;
fileLabel.AutoSize = true;
this.Controls.Add(fileLabel);
if(fileCheckBox.Width+fileLabel.Width>largeWidth)
largeWidth = fileCheckBox.Width + fileLabel.Width;
previous = fileCheckBox;
index++;
}