public void removeTabPage(FGLApplicationPanel appPanel) { bool forceClose = false; if (applicationLauncherId == appPanel.ApplicationEnvelopeID) { // They are closing the application panel! if (tabControl1.TabCount > 1) { MessageBox.Show("Application launcher is exiting - all other program will exit too"); forceClose = true; } } if (appPanel == null) { return; } foreach (TabPage tp in this.tabControl1.TabPages) { if (tp.Controls.Contains(appPanel)) { tabControl1.TabPages.Remove(tp); appPanel.Dispose(); appPanel = null; } } if (this.tabControl1.TabCount == 0 || forceClose) { dontPrompt = true; this.Close(); this.Dispose(); } return; }