/// <summary> /// Close from current item. /// </summary> public void close() { if (CurrentItem.Tag2 == "Database") { var ccpanel = (CurrentItem.Tag as cncpanel); ccpanel.Database.Disconnect(); ccpanel.Dispose(); } var dex = Controls.IndexOf(CurrentItem); Controls.RemoveAt(dex); CurrentItem.Dispose(); CurrentItem = Controls.Count == 1 ? null : dex > Controls.Count - 1 ? Controls[dex - 1] as sbutton : Controls[dex] as sbutton; }