在事件触发后处置Usercontrol。 [英] Disposing a Usercontrol after an event fired.

查看:93
本文介绍了在事件触发后处置Usercontrol。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有问题,投入了很多时间,但仍然没有取得令人满意的结果。这个问题可能听起来很奇怪,但就我不熟悉C#编程而言,我需要你的帮助。



我有WinForm用户控件正被加载到我的面板中MainForm的。我需要得到帮助的是,当我在我的MainForm中加载第二个用户控件时,我仍然可以在我的MainForm中看到第一个用户控件加载到面板。有什么方法可以处置第一个用户控件并将其他用户控件加载到我的主窗体?

Hi All,
I have problem and investing many hours on it but still didn't achieved a satisfying result. This question may sound weird but as far as i am new to C# programming i need your help.

I have WinForm User Controls which are being loaded to a panel in my MainForm. The thing i need to get help with is that when I am loading the second User Control in my MainForm i still can see the first User Control Loaded to panel in my MainForm. Is there any way that i could dispose the first user control and load the other user control to my main form?

private void navBarItem1_LinkPressed(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
       {
               DataEntryLayout DataEntryUC = new DataEntryLayout();
               panelControl1.Controls.Add(DataEntryUC);
               DataEntryUC.Dock = DockStyle.Fill;
               DataEntryUC.Show();
       }

推荐答案

作为类 System.Windows.Forms.UserControl System.ComponentModel.UserControl ,它的方法是 Dispose

http://msdn.microsoft.com/en-us/library/3cc9y48w.aspx [ ^ ]。



-SA
As the class System.Windows.Forms.UserControl is System.ComponentModel.UserControl, it has the method Dispose:
http://msdn.microsoft.com/en-us/library/3cc9y48w.aspx[^].

—SA


这篇关于在事件触发后处置Usercontrol。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆