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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

e1vCommented:
You can set this.ShowInTaskbar = false
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();
           
        }
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.
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;
            }
-
GranModCommented:
PAQed with points refunded (250)

GranMod
Community Support Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.