Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Minimize Form in System Tray

0.00/5 (No votes)
12 Feb 2010 1  
Note that you must select NotifyIcon1 from the ToolBox and set any icon to its icon property plus make 3 buttons or you can write minimize to tray code in the form closing event.Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As...
Note that you must select NotifyIcon1 from the ToolBox and set any icon to its icon property plus make 3 buttons or you can write minimize to tray code in the form closing event.

VB.NET
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click
        Me.WindowState = FormWindowState.Minimized
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button2.Click
        Application.Exit()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button3.Click
        Me.WindowState = FormWindowState.Minimized
        Me.Visible = False
        NotifyIcon1.Visible = True
    End Sub

    Private Sub NotifyIcon1_MouseDoubleClick(ByVal sender As System.Object, _
        ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDoubleClick
        Me.Visible = True
        Me.WindowState = FormWindowState.Normal
        NotifyIcon1.Visible = False
    End Sub
End Class

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here