/// <summary> /// タブを閉じる。 /// </summary> /// <returns></returns> public bool CloseTabPage() { if (!this.CanRedock) { return(true); } for (int i = this.ChildTabPages.Count - 1; i >= 0; i--) { DockingTabPage item = this.ChildTabPages[i]; if (!item.CloseTabPage()) { return(false); } } this.ChildTabPages.Clear(); DockingTab tab = this.Parent as DockingTab; if (tab != null) { tab.SelectedTabControl = this; } this.IsClosing = true; bool result = CloseFormsInTabPage(); this.IsClosing = false; return(result); }
public void ReDockTabPage(DockingTabPage tp) { if (tp.Parent is DockingTab) { DockingTab tabPanel = tp.Parent as DockingTab; //移動 tabPanel.RemoveTabPage(tp); Controls.Add(tp); SelectedTabControl = tp; } }
//*** Add 2009/07/06 End K.Misu #endregion protected override void Dispose(bool disposing) { //*** Add 2009/07/09 Sta K.Misu if (this.ParentTabPage != null) { if (this.ParentTabPage.ChildTabPages.Contains(this)) { this.ParentTabPage.ChildTabPages.Remove(this); } this.ParentTabPage = null; } if (this._ChildTabPages != null) { foreach (DockingTabPage item in this._ChildTabPages) { if (item != null) { item.ParentTabPage = null; } } this._ChildTabPages.Clear(); this._ChildTabPages = null; } //*** Add 2009/07/09 End K.Misu //*** Add Sta BugFix:0004187 2009/05/20 nitta this.objOriginalParent = null; //*** Add End BugFix:0004187 2009/05/20 nitta base.Dispose(disposing); //*** Del Sta BugFix:0004187 2009/04/27 nitta //Disposeが無限ループするので削除 //try //{ // if (null != this.Controls) // { // foreach (Control ctr in this.Controls) // { // if (null != ctr && !ctr.IsDisposed) // { // ctr.Dispose(); // } // } // } //} //catch { } //*** Del End BugFix:0004187 2009/04/27 nitta }
//*** Add 2009/07/09 End K.Misu //*** Add 2009/07/06 Sta K.Misu /// <summary> /// TabPageを閉じます。 /// </summary> protected bool CloseFormsInTabPage() { foreach (Control control in this.Controls) { Form formTemp = control as Form; if (null != formTemp) { bool bIsClosable = true; //this.IsCloseMessageShown = false; Type type = formTemp.GetType(); MethodInfo info = type.GetMethod("ProcessClose", BindingFlags.Instance | BindingFlags.NonPublic); if (null != info) { bIsClosable = (bool)info.Invoke(formTemp, null); } //ProcessCloseがTrueならBusinessFormのMainCloseが既に処理されているので //絶対にCloseしないといけない。 if (bIsClosable) { //this.IsCloseMessageShown = true; formTemp.Close(); //this.IsCloseMessageShown = false; } if (!bIsClosable) { return(false); } } } if (this.Parent is DockingTab) { DockingTab dtpParent = this.Parent as DockingTab; dtpParent.SuspendLayout(); this.SuspendLayout(); dtpParent.RemoveTabPage(this); dtpParent.ResumeLayout(true); if (dtpParent.TabPages.Count > 0) { DockingTabPage selectTabPage = null; if (this.ParentTabPage != null && dtpParent.TabPages.Contains(this.ParentTabPage)) { selectTabPage = this.ParentTabPage; } else { selectTabPage = dtpParent.TabPages[dtpParent.TabPages.Count - 1]; } dtpParent.SelectedTabControl = selectTabPage; } if (this.ParentTabPage != null) { if (this.ParentTabPage.ChildTabPages.Contains(this)) { this.ParentTabPage.ChildTabPages.Remove(this); } this.ParentTabPage = null; } this.Dispose(); } return(true); }