• 0

[VB .NET] Can't hide main form on load event.


Question

Hi,

On Form1_Load(), I try Me.Hide but it doesn't work. Can anyone tell me why?

This application has a tray icon and I want it to start hidden, why doesn't Me.Hide works on the form load event? If I create a button and add Me.Hide() to the button private sub, it works. Heck, if I had a timer with 1ms interval and add Me.Hide() to the timer private sub it works too. This is currently my way of hiding it; I disable the timer right after hiding though.

But I always see the form for a small fraction of a second and I don't want to....

6 answers to this question

Recommended Posts

  • 0

Hide only works if the form is already visible. Load fires just before the form is visible. If you don't want your form shown initially, set it's WindowState to minimized, and set ShowInTaskbar to false.

Then, when you click on your tray icon, set its WindowState to normal, and its ShowInTaskbar to true.

  • 0

I actually had my app running from the Sub Main in a module for some time now as Cephas suggested, but I had Application.Run(frmMain) but I removed the form parameter and it is now working :)

Thank you all.

By the way, my icon is app icon is not showing up in Alt+Tab, why? How can I fix that?

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.