Sakura Sakura - 2 months ago 8
C# Question

How to hide WinForm after it run?


Possible Duplicate:

Single Form Hide on Startup




I want to hide my WinForm after it run (Not minimizing).

I used:

this.Load += new System.EventHandler(this.Form1_Load);
private void Form1_Load(object sender, EventArgs e)
{
Hide();
}


But it's not working. Can you help me do it?

Answer

In the form Load event you can use one of the following tricks:

  1. Make the form completely transparent:

    private void OnFormLoad(object sender, EventArgs e)
    {
         Form form = (Form)sender;
         form.ShowInTaskbar = false;
         form.Opacity = 0;
    }
    
  2. Move the form way off the screen:

    private void OnFormLoad(object sender, EventArgs e)
    {
        Form form = (Form)sender;
        form.ShowInTaskbar = false;
        form.Location = new Point(-10000, -10000);
    } 
    
Comments