Reputation: 1223
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 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
Upvotes: 0
Views: 744
Reputation: 18013
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;
Upvotes: 3