/// <summary> /// Removes the <code>selectedRows</code> from the table. /// </summary> /// <param name="selectedColumns">Collection of indices to the columns that should be removed.</param> /// <param name="selectedRows">Collection of indizes to the rows that should be removed.</param> public void RemoveRowsInColumns(IAscendingIntegerCollection selectedColumns, IAscendingIntegerCollection selectedRows) { // if we remove rows, we have to do that in reverse order Suspend(); for(int selcol=0;selcol<selectedColumns.Count;selcol++) { int colidx = selectedColumns[selcol]; int rangestart=0, rangecount=0; int i = selectedRows.Count-1; while(selectedRows.GetNextRangeDescending(ref i, ref rangestart, ref rangecount)) { this[colidx].RemoveRows(rangestart,rangecount); } } Resume(); }
public void RemoveColumns(IAscendingIntegerCollection selectedColumns, bool disposeColumns) { int nOriginalColumnCount = ColumnCount; int currentPosition = selectedColumns.Count-1; int nFirstColumn=0; int nDelCount=0; while(selectedColumns.GetNextRangeDescending(ref currentPosition, ref nFirstColumn, ref nDelCount)) { // first, Dispose the columns and set the places to null for(int i=nFirstColumn+nDelCount-1;i>=nFirstColumn;i--) { string columnName = GetColumnName(this[i]); if(this.m_ColumnScripts.Contains(this[i])) this.m_ColumnScripts.Remove(this[i]); this.m_ColumnInfo.Remove(m_ColumnsByNumber[i]); this.m_ColumnsByName.Remove(columnName); this[i].ParentObject=null; if(disposeColumns) this[i].Dispose(); } this.m_ColumnsByNumber.RemoveRange(nFirstColumn, nDelCount); } // renumber the remaining columns for(int i=m_ColumnsByNumber.Count-1;i>=nFirstColumn;i--) ((DataColumnInfo)m_ColumnInfo[m_ColumnsByNumber[i]]).Number = i; // raise datachange event that some columns have changed this.EhChildChanged(null, ChangeEventArgs.CreateColumnRemoveArgs(nFirstColumn, nOriginalColumnCount, this.m_NumberOfRows)); // reset the TriedOutRegularNaming flag, maybe one of the regular column names is now free again this._TriedOutRegularNaming = false; }