I have (what should be) a very simple Windows Forms application. There is a “Main” form that is a bunch of data input with a Submit button. When the user presses Submit, I want to display a second form that is a very basic form with only a label on it saying something like, “Please wait…”. I created the second form, and in the Submit button’s Click() I do this:
Form2 f2 = new Form2();
f2.Show();
System.Threading.Thread.Sleep(3000);
f2.Hide();
Form2’s ctor:
public Form2()
{
InitializeComponent();
this.Text = "Form2 that is useless";
}
What I see is the Form2, but where the label should be, I only see the outline of it as a white reactangle with no text. Text foreground and background colors check out (black foreground on “Control” colored background.
I am pulling my hair out here trying to determine why a simple form added with no property changes will not display controls properly. I added a button control and a picture box control and got the same results. the control’s outline shows up, but the contents do not.
Help?
Add:
to Form2’s ctor. And:
In its class.
EDIT:
This doesn’t work. Probably because the
Sleepis executed before theShownevent handler. The solution is to add a:before the
Sleep, instead of the previous solution.This time I tried it. It works.