Guest User

Untitled

a guest
Sep 18th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. How do I make the close button of a Windows Form not close the form but make it invisible?
  2. protected override void OnFormClosing(FormClosingEventArgs e) {
  3. if (IActuallyWantToCloseFlag)
  4. return;
  5.  
  6. var ni = new NotifyIcon(this.components)
  7. {
  8. Icon = someIcon,
  9. Text = "My text",
  10. Visible = true
  11. };
  12. ni.DoubleClick += (sender, args) => { this.Show(); };
  13.  
  14. this.Hide();
  15. e.Cancel = true;
  16. }
  17.  
  18. FormClosing += (sender, args) => { args.Cancel = true; Visible = false; };
Add Comment
Please, Sign In to add comment