I wanted to hide the main window of my app on startup, so I put this in the constructor:
this.Hide();
This doesn't hide my form though. It seems like I can only get buttons to hide the form. Am I doing something wrong here?
Press F5 to build and run the application. Click on the button in the main form to display the sub form. Now, when you press the button in the sub form, the form will be hidden.
To prevent your form from appearing in the taskbar, set its ShowInTaskbar property to False.
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.
Use Me. Opacity = 0 to hide the form on load event.
you can use this line of code. It wont hide it, but it will be minimized:
this.WindowState = FormWindowState.Minimized;
in addition, if you don't want it showing on the task bar either, you can add this line:
this.ShowInTaskbar = false;
But why do you create the form if you don't want it to be visible in the first place?
If you would rather use this.Hide or this.Show you can do this
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
this.Hide();
}
Just override the OnVisibleChanged method and change the visibility of the form in there, something like this:
protected override void OnVisibleChanged(EventArgs e)
{
base.OnVisibleChanged(e);
this.Visible = false;
}
And that's it! Simple and clean.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With