I have run my program step by step, but still, I can’t find where the form.visible is set.
Here is the code of “Form1.cs”:
public Form1()
{
InitializeComponent();
this.Hide();
}
I added this.Hide(); but it didn’t work at all.
and I even modified “Program.cs” from:
Application.Run(new Form1());
to:
Form1 form1=new Form1();
form1.Visible = false;
Application.Run(form1);
But the main form still showed, even adding form1.Enable=false; won’t stop the form from showing. I have also tried adding this.Hide(); in Form1_Load(), it worked but the main form appeared and flashed before it was finally hidden.
I’m totally confused now. So how can I load the main form without showing it? And keep it hidden until I call this.Show();?
Why not override the SetVisibleCore method:
This will hide the form before it even opens up. With a lot of method’s you see a brief flash of the form before its .Visible or similar property is set to “hide”.
Obviously you will need another method to flip ‘showForm’ to true when you want to display it again i.e. NotifyIcon event.