When a user clicks on a specific part of a window, I add a UserControl to the window controls. The UserControl button has a close button. What can I do in the UserControl button handler to destroy the UserControl? There seems to be no .net analogue for calling Win32 DestroyWindow, and there is no Close () method for the control. So far I have this:
private void sbClose_Click(object sender, EventArgs e) { Parent.Controls.Remove(this); this.Dispose(); }
And, if the parent needs to destroy the control, what are the steps? This is what I still have:
Controls.Remove(control); control.Dispose();
winforms
P aul
source share