- Drag a
NotifyIcon and ContextMenuStrip . - Set the "NotifyIcon" context menu to the one you added.
- Add 2 menu items (e.g. Restore, Exit)
Set the resize form event and run the following check
private void MyForm_Resize(object sender, EventArgs e) { if (this.WindowState == FormWindowState.Minimized) this.Hide(); else this.Show(); }
This project can be downloaded as an example.
Don't worry about the right-click event, NotifyIcon will automatically detect it and show ContextMenu
source share