User control does not dispose when dispose is called
I am using user control following way:
Login = new MainMenu();
Login.Parent = this;
Login.Dock = DockStyle.Fill;
Login.SelectionMade += new LoginS.SelectionMadeDelegate(menu_SelectionMade);
Login.Show();
At some point, the user control 开发者_StackOverflow社区fires an event, on which main form reacts like this:
login.SelectionMade -= this.login_SelectionMade;
login.Dispose();
However when checking in debugger, the login instance is still not null. Why? It should be disposed I think
Calling dispose on an object does not set it to null. Dispose would clean up any resources used in the Login control.
You should use:
Login.Dispose();
Login = null;
精彩评论