How do I unload a project from anywhere? I've tried every way I can think but none work. I'm trying to unload from a notifyicon.
Printable View
How do I unload a project from anywhere? I've tried every way I can think but none work. I'm trying to unload from a notifyicon.
The best way would be to close your main form.
Alternatively, you can call
Code:System.Windows.Forms.Application.Exit()
Is your NotifyIcon a member of the startup form? If so it would just be a matter of calling this.Close() from whatever event you choose to handle. Normally you would attach a ContextMenu or ContextMenuStrip (please specify your version in future) to the NotifyIcon with an Exit item, then handle the Click event of that menu item. If your Notifyicon is not a member of your startup form then you call Application.Exit as sunburnt suggested. Just note that no Closing or Clsed events will be raised on your forms in this case. In C# 2.0 the FormClosing and FormClosed events will be raised though.