C# Minimize to system tray on close

前端 未结 7 1128
再見小時候
再見小時候 2020-12-28 09:10

Hi In my c# application I am trying to minimize application to systems tray, when the form is closed. Here is the code I have tried.

   public void MinimizeT         


        
相关标签:
7条回答
  • 2020-12-28 09:39

    You can handle FormClosing Event such as micsoft Form Closing Event as Following example of C#

    private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            // Determine if text has changed in the textbox by comparing to original text.
            if (textBox1.Text != strMyOriginalText)
            {
                // Display a MsgBox asking the user to save changes or abort.
                if (MessageBox.Show("Do you want to save changes to your text?", "My Application",
                    MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    // Cancel the Closing event from closing the form.
                    e.Cancel = true;
                    // Call method to save file...
                }
            }
    }
    
    0 讨论(0)
提交回复
热议问题