private void EHSubCenterChanged(object sender, EventArgs e) { // 重新刷新界面 m_tabControl.SuspendLayout(); Dictionary <int, CDataGridTabPage> oldMap = m_mapSubCenterPage; m_mapSubCenterPage = new Dictionary <int, CDataGridTabPage>(); // 删除原先的分中心页面 foreach (KeyValuePair <int, CDataGridTabPage> item in oldMap) { m_tabControl.RemovePage(item.Value); } // 建立新的分中心页面 // 添加分中心 List <CEntitySubCenter> listSubCenter = CDBDataMgr.Instance.GetAllSubCenter(); for (int i = 0; i < listSubCenter.Count; ++i) { CDataGridTabPage tmp = new CDataGridTabPage() { Title = listSubCenter[i].SubCenterName, BTabRectClosable = false }; tmp.Padding = new System.Windows.Forms.Padding(0, 0, 0, 3); m_mapSubCenterPage.Add(listSubCenter[i].SubCenterID, tmp); if (oldMap.ContainsKey(listSubCenter[i].SubCenterID)) { //Debug.WriteLine("before-{0}:{1}", i,oldMap[listSubCenter[i].SubCenterID].DataGrid.Width); //int width = oldMap[listSubCenter[i].SubCenterID].DataGrid.Width; oldMap[listSubCenter[i].SubCenterID].RemoveDataGrid(); // 内容不均匀分布问题 oldMap[listSubCenter[i].SubCenterID].DataGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None; tmp.DataGrid = oldMap[listSubCenter[i].SubCenterID].DataGrid; tmp.DataGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; //Debug.WriteLine("after-{0}:{1}", i,tmp.DataGrid.Width); //tmp.DataGrid.Width = width; } else { // 新建数据项 tmp.DataGrid = new CDataGridViewSoilRTD(); tmp.DataGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; } m_tabControl.AddPage(tmp); } m_tabControl.ResumeLayout(false); }
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); }