本文主要是介绍dockpanel中DockContent的释放问题,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
例子中 DummyTaskList的属性this.HideOnClose = true;这样该控件关闭时候就不会释放。具体代码调用如下formcontrol.click---->
> WeifenLuo.WinFormsUI.Docking.dll!WeifenLuo.WinFormsUI.Docking.VS2005DockPaneCaption.Close_Click(object sender = {WeifenLuo.WinFormsUI.Docking.VS2005DockPaneCaption+InertButton}, System.EventArgs e = {X = 2 Y = 9 Button = Left}) 行453 + 0x12 字节 C#
private void Close_Click(object sender, EventArgs e)
{
DockPane.CloseActiveContent();
}
public void CloseActiveContent()
{
CloseContent(ActiveContent);
}
internal void CloseContent(IDockContent content)
{
DockPanel dockPanel = DockPanel;
dockPanel.SuspendLayout(true);
if (content == null)
return;
if (!content.DockHandler.CloseButton)
return;
if (content.DockHandler.HideOnClose)
content.DockHandler.Hide();
else
content.DockHandler.Close();
dockPanel.ResumeLayout(true, true);
}
因为设置了该属性,所以IsDisposed 为false,否则为true
if (m_taskList.IsDisposed == false)
{
m_taskList.Show(dockPanel);
}
为了关闭dockcontent,可以使用m_taskList.DockPanel = null;这样m_taskList不显示,但是没有释放该窗体,可以继续调用m_taskList.Show(dockPanel)显示该窗体。
关闭document代码
IDockContent[] documents = dockPanel.DocumentsToArray();
foreach (IDockContent content in documents)
content.DockHandler.Close();
这篇关于dockpanel中DockContent的释放问题的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!