daily pastebin goal
33%
SHARE
TWEET

Untitled

a guest Sep 18th, 2018 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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; };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top