I have a very simple custom UserControl, named MyControl
In my form I have this code (I tried to put it into LoadEvent and constructor, after InitalizeCompoment):
var crl = new MyControl();
Controls.Add(ctrl);
ctrl.HandleDestroyed+=(sender,evt) => { MessageBox.Show("Destroyed") };
But when I close the form handler is never called.
If it’s on the main form, then I don’t think the event gets called. Try disposing the control in the
FormClosingevent in order to force the event to be called:Another way is to add the
FormClosingevent to theUserControl:or in Lambda methodology: