3

I added notifyIcon to the container and set Visible = true option, but no icon appeared.

private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
            this.SuspendLayout();
            // 
            // notifyIcon1
            // 
            this.notifyIcon1.Text = "Manager";
            this.notifyIcon1.Visible = true;
            // 
            // Form1
            // 
            this.ClientSize = new System.Drawing.Size(0, 0);
            this.ShowInTaskbar = false;
            this.Visible = false;

        }
BILL
  • 4,711
  • 10
  • 57
  • 96

2 Answers2

2

I believe you need to add a few more events for this to work, Hope this helps

public Form2()
    {
        InitializeComponent();
        notifyIcon1.Icon = SystemIcons.Asterisk;
        notifyIcon1.DoubleClick += new EventHandler(notifyIcon1_DoubleClick);// to bring it back
        this.Resize += new EventHandler(Form2_Resize);// to move it to tray
    }

    void notifyIcon1_DoubleClick(object sender, EventArgs e)
    {
        Show();
        this.BringToFront();
        this.WindowState = FormWindowState.Normal;
    }

    void Form2_Resize(object sender, EventArgs e)
    {
        if (this.WindowState ==FormWindowState.Minimized)
            Hide();
    }
V4Vendetta
  • 37,194
  • 9
  • 78
  • 82
0

notify Icon is shown when form is minimize. Try this

 this.WindowState = FormWindowState.Minimized;
Javed Akram
  • 15,024
  • 26
  • 81
  • 118