Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide a Form when X-button pressed 1

Status
Not open for further replies.

d00ape

Programmer
Apr 2, 2003
171
SE
I hane an application where one of my dialogs is created when the program starts. I like to call Form.Show() and Form.Hide() to show and hide the form.

When the user presses the system-X button the form is per default disposed. How do I prevent that I just want a Form.Hide() when the user does that so that I can call Form.Show() again without making a new instance of it.
 
That's actually very easy.

in the closing event of the form/dialog

Code:
e.cancel = true;
this.hide();

I hope that's all good c#.

Christiaan Baes
Belgium

"My new site" - Me
 
Perfect Thanks!!

protected override void OnClosing(CancelEventArgs e)
{
e.Cancel = true;
Hide();
//base.OnClosing(e);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top