I am writing an application in VB.Net, and I have an issue in the fact that when I open my login form, my tray icon is duplicated. However, when I open my about form, it's not. Here's my code:
Private Sub lblAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblAbout.Click
Private Sub btnLogIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogIn.Click
ntfTray.Visible = False
My psychic debugging powers tell me you are using the default instances of your
I highly recommend NOT using the default instances, forget that they exist, banish them from your mind forever.
You need to declare new instances of those forms, and hide / show those instances as needed, like this:
Dim frm as new About() frm.ShowDialog()
This should make sure that all your instances, and their persistent objects, such as the
NotifyIcon don't get duplicated.
Depending on your application design you may need to create longer lived instances of these forms and keep around with longer lifetimes than simple method scope would allow. You can do that with class level fields.