Skip to content

Instantly share code, notes, and snippets.

@WildGenie
Created February 27, 2017 21:20
Show Gist options
  • Save WildGenie/49f6160dfd08d0a19adf0b06ff9cb90e to your computer and use it in GitHub Desktop.
Save WildGenie/49f6160dfd08d0a19adf0b06ff9cb90e to your computer and use it in GitHub Desktop.
protected override void OnParentChanged(EventArgs e)
{
base.OnParentChanged(e);
if (parentForm != null)
{
parentForm.Closing -= parentForm_Closing;
}
parentForm = FindForm();
if (parentForm != null)
parentForm.Closing += parentForm_Closing;
}
void parentForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
parentForm.Closing -= parentForm_Closing;
parentForm = null;
//closing code
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment