close button on control box of form
C#
2
Posts
2
Posters
0
Views
1
Watching
-
Hi there Can anyone tell me how i can change the action of the close button on the control box of the form. i want to hide the form rather than to close it when the close button is pressed. VisionTec
Handle the
Form.Closing
event (or override the related method for derived classes), cancel it, and do something else:public class MyForm : Form
{
// ...
protected override void OnClosing(CancelEventArgs e)
{
this.Hide();// Code below probably isn't necessary unless handling the event externally, // but this gives other listeners a chance to override the behavior // if necessary. e.Cancel = true; base.OnClosing(e);
}
}Microsoft MVP, Visual C# My Articles