How to hide and show windows form in system tray ?

windows form hide and show During form resize event, check user click minimize button by FormWindowState and if the window state is minimized.
Assign notification to show visible and hide windows form. When user double click notifyIcon revert windows form to original state.

Download

Example Source Snippets - FormHideToSystemTray.zip

namespace :using System.Windows.Forms

C# hide windows form to system tray


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FormHideToSystemTray
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.Icon = global::FormHideToSystemTray.Properties.Resources.favicon;
            nicoHide.Icon = global::FormHideToSystemTray.Properties.Resources.favicon;
        }

        private void Form1_Resize(object sender, EventArgs e)
        {
            nicoHide.BalloonTipTitle = "Hide Form";
            nicoHide.BalloonTipText = "Form Minimized to System Tray.";             

            if (FormWindowState.Minimized == this.WindowState)
            {
                nicoHide.Visible = true;
                nicoHide.ShowBalloonTip(4);
                this.Hide();
            }
            else if (FormWindowState.Normal == this.WindowState)
            {
                nicoHide.Visible = false;
            }       
        }

        private void nicoHide_MouseDoubleClick(object sender, MouseEventArgs e)
        {       
            this.Show();
            this.WindowState = FormWindowState.Normal;       
        }
    }
}

                 

smartsnipps.ecomparefiles.com © 2019, All Rights Reserved | Disclaimer: smartsnipps.eCompareFiles.com is free to use any code snippets without guarantee