-->

Friday, January 1, 2016

Example of NotifyIcon system tray in windows form c#

Example of NotifyIcon system tray in windows form c#

If you want to show your windows form application in NotifyIcon toolBar then you can use this example. When you press minimize button of windows form then your application should minimized in system tray. 
Try these steps to minimized your application as System Tray:
Step-1 : Add a new  windows form into your project
Step-2 : Add a NotifyIcon control in currently added form.
Step-3 : Select Show smart tag, add icon file in NotifyIcon control.



Step-4 : Add the following code in code file with respective events

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 WindowsFormsApplication5
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void Form3_Resize(object sender, EventArgs e)
        {
            if (WindowState==FormWindowState.Minimized)
            {

                ShowIcon = false;
                notifyIcon1.Visible = true;
                notifyIcon1.ShowBalloonTip(1000);
            }
        }

        private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            ShowInTaskbar = true;
            notifyIcon1.Visible = false;
            WindowState = FormWindowState.Normal;
        }

        private void Form3_Load(object sender, EventArgs e)
        {
            notifyIcon1.BalloonTipText = "Application minimized";
            notifyIcon1.BalloonTipTitle = "dotprogramming.blogspot.com";
        }
    }
}

Code generates the following output
Example of NotifyIcon system tray in windows form c#

Read other related articles

Also read other articles

© Copyright 2013 Computer Programming | All Right Reserved