5

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?

Community
  • 1
  • 1
NoName
  • 7,940
  • 13
  • 56
  • 108

3 Answers3

13

In the form Load override 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);
    } 
    
Pavel Vladov
  • 4,707
  • 3
  • 35
  • 39
  • Sometimes the Opacity=0 may not work if you are hosting some weird control. You can set it to form.Opacity = 0.01. – Jason Ching Jun 29 '17 at 10:58
4

Try to hide the form after it has been shown and not after it has been loaded, use the Shown event instead of the Load event

polkduran
  • 2,533
  • 24
  • 34
  • Yeah, Try this code to hide. protected override void OnLoad(EventArgs e) { Visible = false; // Hide form window. ShowInTaskbar = false; // Remove from taskbar. Opacity = 0; base.OnLoad(e); } – Metallic Skeleton Oct 28 '16 at 05:04
3

You can't easily hide the form but what you can do is set the Opacity to 0, for example:

this.Opacity = 0;

If you Don't want the user to be able to see the app at all set this:

this.ShowInTaskbar = false;

Then they won't be able to see the form in the task bar and it will be invisible.

I believe this solved your "no use minimized" requirement??

TheKingDave
  • 926
  • 1
  • 8
  • 16