Like so:
private void MyForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
e.Cancel = true;
Hide();
}
}
(via Tim Huffman)
More Related Contents:
- Interaction between forms — How to change a control of a form from another form?
- Loop through Textboxes
- Cursor.Current vs. this.Cursor
- How to detect Windows shutdown or logoff
- How to handle click event in Button Column in Datagridview?
- List vs BindingList Advantages/DisAdvantages
- Combining multiple Attributes to a single Attribute – Merge Attributes
- Create dynamic buttons in a grid layout – Create a magic square UI
- Proper way to dispose a new Form
- How do I execute code AFTER a form has loaded?
- How do I group Windows Form radio buttons?
- Forms not responding to KeyDown events
- DateTimePicker: pick both date and time
- C# ListView Column Width Auto
- How to highlight wrapped text in a control using the graphics?
- How can I make a ComboBox non-editable in .NET?
- winforms html editor [closed]
- Key Events: ProcessCmdKey
- Setting a Windows form to be bottommost
- How can we change the background color of all other forms from one form?
- DataGridView keydown event not working in C#
- Binding an enum to a WinForms combo box, and then setting it
- Detect change of resolution c# WinForms
- How to create a form with a border, but no title bar? (like volume control on Windows 7)
- How to refresh datagridview when closing child form?
- DataGridView Image for Button Column
- Change ComboBox Border Color in Windows Forms
- How to set text to a control from resource file in design time?
- Passing a variable between Windows Forms forms
- What does “Beta: Use Unicode UTF-8 for worldwide language support” actually do?