Close this search box.

How to hide a form instead of closing it – with C# .Net

Doing some winforms dev for a change – and had a need to hide a form, instead of closing it, when the user clicked the standard windows close form button (little cross [x] icon on the top right corner of the form).

The solution is to create a handler for the FormClosing event of the form, then force the form to be hidden, then, the important part, cancel the close event…


// Use this event handler for the FormClosing event.
private void MyForm_FormClosing(object sender, FormClosingEventArgs e)
  e.Cancel = true; // this cancels the close event.


This article is part of the GWB Archives. Original Author: Tim Huffam

Related Posts