private void EnableTabPages(Boolean Enable) { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (this.tabControl1.InvokeRequired) { EnableTabPagesCallback d = new EnableTabPagesCallback(EnableTabPages); this.Invoke(d, new object[] { Enable }); } else { // enable or disable the tab pages if (Enable) { tabControl1.TabPages.Add(tabPageCollection); tabControl1.TabPages.Add(tabPageStore); tabControl1.TabPages.Add(tabPageLobby); if (this.Admin) { tabControl1.TabPages.Add(tabPageAdmin); } if (this.Gaming) { tabControl1.TabPages.Add(tabPageGame); } } else { tabControl1.TabPages.Remove(tabPageCollection); tabControl1.TabPages.Remove(tabPageStore); tabControl1.TabPages.Remove(tabPageLobby); tabControl1.TabPages.Remove(tabPageGame); tabControl1.TabPages.Remove(tabPageAdmin); } } }