how to handle 'Close' Event of a Group Box in C#
Someone let me know how to handle Group Box Close event, as i didn'开发者_运维问答t see any event handler for this in .net.
GroupBox
es are strictly visual elements, used to group related controls together on a form. By default, there is no way to close them, so there's no event to handle.
If you want to hide the box for some reason, you're allowed to handle its Click
event, and change its visibility there.
Updated: If you want to handle your dialog box being closed, you can handle either the Closing
event (to perform work prior to the box closing) or the Closed
event (to perform work after the box has closed.)
You can add the handler in your Form
's constructor:
public void MyForm()
{
this.Closing += MyClosingHandler;
this.Closed += MyClosedHandler;
}
private void MyClosingHandler(object sender, System.EventArgs e)
{
// Perform work prior to dialog closing (maybe prompting "are you sure?")
}
private void MyClosedHandler(object sender, System.EventArgs e)
{
// Perform work after the dialog has closed
}
精彩评论