Windows Forms: How to create a System tray Notification in C#
By FoxLearn 7/18/2017 8:59:34 PM 8.16K
How to create a system tray in c# .net using NotifyIcon control, and how to write the code so that when you minimize your application, it hides itself and shows a balloon tip, with custom text as the title of the balloon tip and custom text as the balloon tip description
Step 1: Click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "SystemTray" and then click OK
Step 2: Design your form as below
Add a ContextMenuStrip, NotifyIcon to your windows form application
Step 3: Add code to handle your windows forms as below
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace SystemTray { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void showToolStripMenuItem_Click(object sender, EventArgs e) { this.Show(); } private void exitToolStripMenuItem_Click(object sender, EventArgs e) { //Exit your program Application.Exit(); } private void Form1_Move(object sender, EventArgs e) { if (this.WindowState == FormWindowState.Minimized) { this.Hide(); //Show ballon tip notifyIcon1.ShowBalloonTip(1000, "Important notice", "Something important has come up. Click this to know more.", ToolTipIcon.Info); } } private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) { this.Show(); } } }
VIDEO TUTORIALS
- Windows Forms: How to make an Application auto run on Windows startup in C#
- Windows Forms: Wait Form Dialog in C#
- How to create a Lucky Draw games in C#
- Windows Forms: Youtube Search with Paging in C#
- Windows Forms: Text to speech in C#
- Windows Forms: Print Picture Box in C#
- Windows Forms: Advanced Filter DataGridView in C#
- Windows Forms: Progress Bar in C#
Categories
Popular Posts
Visual Studio: Auto increment version
04/01/2024
What is ARM architecture?
04/01/2024