/// <summary> /// 从表格中移除类别 /// </summary> /// <param name="categories">类别</param> public void RemoveCategoriesFromCategoryGrid(List <UserSecurityCategory> categories) { if (m_gridCategory.EditTextBox != null) { m_gridCategory.OnCellEditEnd(null); } m_gridCategory.BeginUpdate(); Dictionary <String, String> removeKeys = new Dictionary <String, String>(); int categoriesSize = categories.Count; for (int i = 0; i < categoriesSize; i++) { UserSecurityCategory category = categories[i]; removeKeys[category.m_categoryID] = ""; } int rowSize = m_gridCategory.GetRows().Count; for (int i = 0; i < rowSize; i++) { GridRow row = m_gridCategory.GetRow(i); String categoryID = row.GetCell(0).GetString(); if (removeKeys.ContainsKey(categoryID)) { m_gridCategory.RemoveRow(row); row.ClearCells(); row.Dispose(); rowSize--; i--; } } removeKeys.Clear(); m_gridCategory.EndUpdate(); m_gridCategory.Invalidate(); }