I am trying to use NotifyIcon to show some information to the user in VB Net.
It is working well, but when the Balloon Tip closes, I set the NotifyIcon visibility to false, the Notify Icon disappears from the tray as I intended, but with it, the notification in the notification panel disappears as well.
How can I get rid of the icon but keep the notification in the notification panel?
Here is some code to reproduce the issue:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim n As New Notification("I need some cake!", "Hunger", ToolTipIcon.Info, Me.Icon)
n.ShowBalloon()
End Sub
Class Notification
Private ni As System.Windows.Forms.NotifyIcon
Public Sub New(text As String, title As String, icon As ToolTipIcon, ic As Icon)
Me.ni = New System.Windows.Forms.NotifyIcon
ni.Icon = ic
ni.BalloonTipText = text
ni.BalloonTipTitle = title
ni.BalloonTipIcon = icon
ni.Visible = True
AddHandler ni.BalloonTipClosed, AddressOf BalloonClosed
End Sub
Public Sub ShowBalloon()
ni.ShowBalloonTip(20000)
End Sub
Private Sub BalloonClosed(sender As Object, e As System.EventArgs)
sender.Visible = False
sender.Dispose()
End Sub
End Class