How can I make the close button on a form effectively act as a 'Hide' button?
Is there a way to abort the FormClosing
event?
Answer: To disable the Close button on an Access form, open the form in Design view. Under the View menu, select Properties. When the Properties window appears, set the "Close Button" property to No.
the first one is to set the border style to "none" in the properties menu, however this will completely remove all buttons and the "windows header thingy" in the top on the window. the second method is to set the controlBox property to false.
You can't remove close Button from JFrames, but you can disable by calling setDefaultCloseOperation(WindowConstants. DO_NOTHING_ON_CLOSE) on that JFrame.
You could just capture the FormClosing
event and stop the default action, then instead of closing the form just hide it:
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
this.Hide();
}
It should be pretty straight forward:
To cancel the closure of a form, set the
Cancel
property of theFormClosingEventArgs
passed to your event handler totrue
.
Concerning part two of the question with hiding the window, hide to taskbar or hide to notification area?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With