Notification Area Icon in C# Windows Forms


In Windows there is a Taskbar with a Notification area (historically known as the system tray or status area) with icons. Typically in the bottom-right a notification icon notifies the user of certain information.

Example: we generally have some software installed in our machine and we periodically get the following notifications.



We can create a notification icon using C# Windows Forms as per requirements.
The following is a snapshot of an notification icon that pops up when the user starts the application.



  1. Add a Windows application

    Add window application
  2. Add a NotifyIcon as in the screen below.

    Add NotifyIcon as per screen
  3. the following control will be added (notiyicon) to the application:

  4. Add the following code to the form:

    1. protected void Displaynotify()  
    2. {  
    3.     try  
    4.     {  
    5.         notifyIcon1.Icon = new       System.Drawing.Icon(Path.GetFullPath(@"image\graph.ico"));  
    6.         notifyIcon1.Text = "Export Datatable Utlity";  
    7.         notifyIcon1.Visible = true;  
    8.         notifyIcon1.BalloonTipTitle = "Welcome Devesh omar to Datatable Export Utlity";  
    9.         notifyIcon1.BalloonTipText = "Click Here to see details";  
    10.         notifyIcon1.ShowBalloonTip(100);  
    11.     }  
    12.     catch (Exception ex)  
    13.    {
    14.    }  

  5. Call the preceding method at form_load as in the following:

    1. private void Form1_Load(object sender, EventArgs e)  
    2. {  
    3.      Displaynotify();  

  6. Complete Code: 

  7. Running the application:

    Running application

  8. Go to the bottom-right status bar as in the following:

    status bar
  9. Handling events:

    Right-click on the notifyincon to see the property window:

    property window
  10. Add code for the notifyicon click as in the following:

    1. private void notifyIcon1_Click(object sender, EventArgs e)  
    2. {  
    3.      MessageBox.Show("DEVESH !!! you clicked on notifyicon");  
    4. }  

  11. Run the code and click on the following icon:



We have learned the basics of notifyicons in C# Windoes Forms.

Up Next
    Ebook Download
    View all
    View all