Minimise to System Tray not Taskbar as well.

Warning, c# N00b :-)

I'd like to minimise my app to the system tray, rather than the taskbar.
I've created a NotifyIcon and used the following code to hide the app from the taskbar:

  private void Form1_Resize(object sender, System.EventArgs e)
   {
   if (FormWindowState.Minimized == WindowState)
   Hide();
   }

The app when minimised goes to the system tray just fine but I still have the app on the taskbar too.
Everywhere I've hunted seems to show the same code to what I've already quoted - Am I missing something obvious?
Thanks,

- M.
LVL 1
nikez2k4Asked:
Who is Participating?
 
GranModCommented:
PAQed with points refunded (250)

GranMod
Community Support Moderator
0
 
e1vCommented:
You can set this.ShowInTaskbar = false
0
 
nikez2k4Author Commented:
Thanks for the reply... set it in .. here, or elsewhere?

        private void Form1_Resize(object sender, System.EventArgs e)
        {
            if (FormWindowState.Minimized == WindowState)
                Hide();
           
        }
0
 
e1vCommented:
Hello, you could set ShowInTaskbar false when WindowState == Minimized and true when its not minimized.

But it shouldn't be necessary setting it at all... When I tried your Resize-method my program dissapeared form the taskbar just fine.
So there must be something else going on.
0
 
nikez2k4Author Commented:
Went with this, which seems to work (not sure why the other one didnt)

-
  private void Form1_Resize(object sender, System.EventArgs e)
        {
            //Check to see if the window has been Minimized:
            if (this.WindowState == FormWindowState.Minimized)
            {
                //Remove the Program from the Task Bar:
                this.ShowInTaskbar = false;
                //Show the Icon in the system tray:
                notifyIcon1.Visible = true;
            }
-
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.