Reputation: 955
I am trying to show icon on the taskbar, well i did this in this way.
ResourceManager resManager = new ResourceManager("TestAgent.Properties.Resources", GetType().Module.Assembly);
notifyicon.Icon = (Icon)resManager.GetObject("TestAgent");
notifyicon.Visible = true;
notifyicon.Text = "Test Agent";
this.Hide();
this.ShowInTaskbar = false;
this.SetVisibleCore(false);
On other side when try remove icon from the taskbar doing in this way.
notifyicon.Visible = false;
notifyicon = null;
rulehandler = null;
I did this successfully but the problem is when try to remove icon from the taskbar it remove icon successfully from the taskbar but not hide the icon, When hover the mouse on the icon it removes.
Is there anyway to remove icon without mouse hover? I am doing this in windows form with c#
Upvotes: 1
Views: 7536
Reputation: 55
simply write notifyIcon.Visible = false;
(capital I in Icon) before closing the window, and you are good to go.
As simple as that.
Upvotes: 0
Reputation: 3804
Simply Dispose it.
In a Windows Form you can subscribe to the global event ApplicationExit ...
Application.ApplicationExit += new EventHandler(this.OnApplicationExit);
private void OnApplicationExit(object sender, EventArgs e) {
notifyicon.Dispose();
}
Upvotes: 2