NotifyIcon : Display Windows Form in System Tray

NotifyIcon : Display Windows Form in System Tray

  • Comments 1

While talking to different people I get this question. And in Visual Studio it is very easy to do,

 

You need Windows Forms Application, then drag and drop NotifyIcon there. Set one icon with that control so that it is visible,

 

public partial class Form1 : Form

{

    public Form1()

    {

        InitializeComponent();

    }

 

    private void Form1_Load(object sender, EventArgs e)

    {

   

        notifyIcon1.BalloonTipText = "Current Time : " + DateTime.Now.ToString();

        notifyIcon1.BalloonTipTitle = "This is Test";

 

        //Keep the Baloon for 1 second

        notifyIcon1.ShowBalloonTip(1000);

 

        //Start the window in Minimized Mode

        WindowState = FormWindowState.Minimized;

 

    }

 

 

    //While minimizing the Form show only in System Tray

    private void Form1_Resize(object sender, EventArgs e)

    {

        if (FormWindowState.Minimized == WindowState)

        {

            Hide();

        }

    }

 

    //Restore the Form State Back to normal

    private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)

    {           

        WindowState = FormWindowState.Normal;

        Show();

    }       

}

 

Namoskar!!!

 

Leave a Comment
  • Please add 2 and 2 and type the answer here:
  • Post