System.Data.DataTable.OnRemoveColumn C# (CSharp) Method

OnRemoveColumn() protected method

Notifies the that a is being removed.
protected OnRemoveColumn ( DataColumn column ) : void
column DataColumn
return void
        protected virtual void OnRemoveColumn(DataColumn column) { }

Usage Example

Example #1
0
        /// <summary>
        /// Removes the specified DataColumn object from the collection.
        /// </summary>
        /// <param name="column">The DataColumn to remove.</param>
        public void Remove(DataColumn column)
        {
            if (column == null)
            {
                throw new ArgumentNullException("column", "'column' argument cannot be null.");
            }

            if (!Contains(column.ColumnName))
            {
                throw new ArgumentException("Cannot remove a column that doesn't belong to this table.");
            }

            string dependency = GetColumnDependency(column);

            if (dependency != String.Empty)
            {
                throw new ArgumentException("Cannot remove this column, because it is part of " + dependency);
            }

#if NOT_PFX
            CollectionChangeEventArgs e = new CollectionChangeEventArgs(CollectionChangeAction.Remove, column);
#endif

            int ordinal = column.Ordinal;
            UnregisterName(column.ColumnName);
            base.List.Remove(column);

            // Reset column info
            column.ResetColumnInfo();

            //Update the ordinals
            for (int i = ordinal; i < this.Count; i++)
#if NET_2_0
            { this[i].Ordinal = i; }
#else
            { this[i].SetOrdinal(i); }
#endif

            if (parentTable != null)
            {
                parentTable.OnRemoveColumn(column);
            }

            if (column.AutoIncrement)
            {
                autoIncrement.Remove(column);
            }

            column.PropertyChanged -= new PropertyChangedEventHandler(ColumnPropertyChanged);

#if NOT_PFX
            OnCollectionChanged(e);
#endif
        }
All Usage Examples Of System.Data.DataTable::OnRemoveColumn
DataTable