Simple Notify Icon in C#

Submitted by: 
Language: 
Visitors have accessed this post 185 times.

In this tutorial, I will teach you how to create a notify icon in c#. This method has the ability to hide the form and it will be displayed in the system tray. It also gets the current date and OS version of your computer.

Creating Application

Step 1

Open Microsoft Visual Studio 2015 and create a new windows form application for c#.
ps1

Step 2

Do the form just like shown below.
ps2

Step 3

Click the contextMenuStrip and add the following item.
ps3

Step 4

Click the notifyIcon and go to the properties. In the properties, select the contextMenuStrip and add an icon of it.
ps4
Note: You cannot view the notifyIcon in the system tray without adding an icon of it.

Step 5

Add the following codes for displaying the current date and OS version in the first load of the form.

  1. private void Form1_Load(object sender, EventArgs e)
  2. {
  3. lblCurtime.Text = DateTime.Now.ToString();
  4.  
  5. OperatingSystem operationsystem = Environment.OSVersion;
  6. lblCurOS.Text = operationsystem.ToString();
  7. }

Step 6

Do the following codes to add the notifyIcon in the system tray.

  1. private void button1_Click(object sender, EventArgs e)
  2. {
  3. this.Hide();
  4. notifyIcon1.Visible = true;
  5. notifyIcon1.Text = "System Information";
  6. }

Step 7

Write the following codes for showing the current date when the “Current Date” is clicked.

  1. private void currentDateToolStripMenuItem_Click(object sender, EventArgs e)
  2. {
  3. MessageBox.Show("Today's date is " + DateTime.Now.ToString() + ".");
  4. }

Step 8

Do the following codes for showing the OS Version when the “OS Version” is clicked.

  1. private void oSVersionToolStripMenuItem_Click(object sender, EventArgs e)
  2. {
  3. OperatingSystem operationsystem = Environment.OSVersion;
  4. MessageBox.Show(operationsystem.ToString());
  5. }s

Step 9

Write the following codes for restoring the form.

  1. private void restoreToolStripMenuItem_Click(object sender, EventArgs e)
  2. {
  3. notifyIcon1.Visible = false;
  4. this.Show();
  5. }

Step 10

This code is for exit.

  1. private void exitToolStripMenuItem_Click(object sender, EventArgs e)
  2. {
  3. this.Close();
  4. }

You can download the complete source code and run it on your computer.
For any questions about this article. You can contact me @
Email – [email protected]
Mobile No. – 09305235027 – TNT
Or feel free to comment below.


Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.