Live Chat Icon For mobile
Live Chat Icon

How do I add an application to the Window’s Tray

Platform: WinForms| Category: Tips

In design mode, you drop a NotifyIcon object on your form. You can then drop a ContextMenu on your form and add this menu to the NotifyIcon’s ContextMenu property. This menu will be seen when the user rightclicks the try icon. You can add a handler for the NotifyIcon’s Click event to catch the action of a user clicking the icon.

From code, you create an instance of NotifyIcon, set properties, hook any handlers you want, and then make it visible. Here are some VB snippets.

	Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		Dim trayItem As NotifyIcon = New NotifyIcon()
		trayItem.Icon = SystemIcons.Question
		trayItem.Visible = True	
		AddHandler trayItem.Click, New EventHandler(AddressOf HandleTrayClick)
	End Sub

	Private Sub HandleTrayClick(ByVal sender As Object, ByVal e As EventArgs)
		MessageBox.Show('Tray item clicked')
	End Sub

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.