Minimise To System Tray in VB.Net

Here's how to make your VB.Net form minimise to the system tray (next to the clock) instead of the task bar.
  • Add a NotifyIcon to your form by double-clicking on it in the Toolbox. Call in ni. Change its Icon property to the same icon you used for your form.
  • In your form's Form.Load function, add:
    ni.Visible = False
    			
  • Create/modify the SizeChanged event on your form like so:
    Private Sub Form_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) _
    	Handles MyBase.SizeChanged
    
    	If Me.WindowState = FormWindowState.Minimized Then
    		Me.WindowState = FormWindowState.Minimized
    		Me.Visible = False
    		Me.ni.Visible = True
    	End If
    
    End Sub
    			
  • Create a click event for your NotifyIcon like:
    Private Sub ni_Click(ByVal sender As Object, ByVal e As System.EventArgs) _
    	Handles ni.Click
    
    	Me.Visible = True
    	Me.WindowState = FormWindowState.Normal
    	Me.ni.Visible = False
    
    End Sub