Articles → CSHARP → Notifyicon In C#

Notifyicon In C#






Purpose




Picture showing the notification area of the operating system
Click to Enlarge


Example






using System;
using System.Windows.Forms;

namespace NotifyIconDemo {
  public partial class Form1: Form {
    public Form1() {
      InitializeComponent();
    }
    NotifyIcon notifyIcon = new NotifyIcon();
    private void btnNotifyIcon_Click(object sender, EventArgs e) {

      notifyIcon.Visible = true;
      this.WindowState = FormWindowState.Minimized;
      this.ShowInTaskbar = false;
      notifyIcon.ShowBalloonTip(10000);

    }

    private void Form1_Load(object sender, EventArgs e) {

      notifyIcon.Icon = System.Drawing.Icon.ExtractAssociatedIcon("images\\favicon.ico");
      notifyIcon.Text = "Notify Icon Message";
      notifyIcon.BalloonTipText = "Notify Balloon Message";
      notifyIcon.DoubleClick += NotifyIcon_DoubleClick;
    }

    private void NotifyIcon_DoubleClick(object sender, EventArgs e) {
      notifyIcon.Visible = false;
      this.WindowState = FormWindowState.Normal;
      this.ShowInTaskbar = true;
    }
  }
}



Output




Picture showing the windows form on load
Click to Enlarge



Picture showing the NotifyIcon in the notification area of the operating system
Click to Enlarge




Posted By  -  Karan Gupta
 
Posted On  -  Saturday, December 26, 2020

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250