private void EHSubCenterChanged(object sender, EventArgs e) { // 重新刷新界面 m_tabControl.SuspendLayout(); Dictionary <int, CListViewTabPage> oldMap = m_mapSubCenterPage; m_mapSubCenterPage = new Dictionary <int, CListViewTabPage>(); // 删除原先的分中心页面 foreach (KeyValuePair <int, CListViewTabPage> item in oldMap) { m_tabControl.RemovePage(item.Value); } // 建立新的分中心页面 // 添加分中心 List <CEntitySubCenter> listSubCenter = CDBDataMgr.Instance.GetAllSubCenter(); for (int i = 0; i < listSubCenter.Count; ++i) { CListViewTabPage tmp = new CListViewTabPage() { Title = listSubCenter[i].SubCenterName, BTabRectClosable = false }; tmp.Padding = new System.Windows.Forms.Padding(0, 0, 0, 3); if (oldMap.ContainsKey(listSubCenter[i].SubCenterID)) { tmp.ListView = oldMap[listSubCenter[i].SubCenterID].ListView; } else { tmp.ListView = new CListViewStationState() { BHorizentalScroolVisible = false }; //, PageRowCount = 300 }; } m_mapSubCenterPage.Add(listSubCenter[i].SubCenterID, tmp); m_tabControl.AddPage(tmp); } m_tabControl.ResumeLayout(false); }
private void InitSubCenterLayout() { m_mapSubCenterPage = new Dictionary <int, CListViewTabPage>(); m_tabControl.SuspendLayout(); m_lvStationStateAllPage = new CListViewTabPage() { Title = "所有站点", BTabRectClosable = false }; m_lvStationStateAllPage.Padding = new System.Windows.Forms.Padding(0, 0, 0, 3); m_lvStationStateAllPage.ListView = new CListViewStationState() { BHorizentalScroolVisible = false }; //, PageRowCount = 300 }; m_tabControl.AddPage(m_lvStationStateAllPage); // 添加分中心 List <CEntitySubCenter> listSubCenter = CDBDataMgr.Instance.GetAllSubCenter(); for (int i = 0; i < listSubCenter.Count; ++i) { CListViewTabPage tmp = new CListViewTabPage() { Title = listSubCenter[i].SubCenterName, BTabRectClosable = false }; tmp.Padding = new System.Windows.Forms.Padding(0, 0, 0, 3); tmp.ListView = new CListViewStationState() { BHorizentalScroolVisible = false }; //, PageRowCount = 300 }; m_mapSubCenterPage.Add(listSubCenter[i].SubCenterID, tmp); m_tabControl.AddPage(tmp); } m_tabControl.ResumeLayout(false); }