开发者

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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜