I have an application that is a part of a solution of projects. In this project I would like for it to start up form to be invisible, but still have a notification icon in the tray visible for this form.
I know that adding me.hide
into the form_load
doesn't work. I tried adding a module that instantiates the startup form and I set it as the startup object. Although that didn't work either. I am running out of ideas to have this form invisible. Could anyone help out? I am using VB.NET.
Use Me.Opacity = 0
to hide the form on load event.
Then use the following code in the form.Shown event
Me.Hide()
Me.Opacity = 100
Paste this in your form code:
Protected Overrides Sub SetVisibleCore(ByVal value As Boolean)
If Not Me.IsHandleCreated Then
Me.CreateHandle()
value = False
End If
MyBase.SetVisibleCore(value)
End Sub
The way that works is that the very first request to show the form, done by the Application class, this code overrides the Visible property back to False. The form will behave as normal after this, you can call Show() to make it visible and Close() to close it, even when it was never visible. Note that the Load event doesn't fire until you show it so be sure to move any code in your event handler for it, if any, to the constructor or this override.
Put this in the form's Shown event
Me.Visible = False
The easiest way is to set the opacity of the form to 0%. When you want it to appear, set it back to 100%
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