asp.net.ph

DataColumnCollection.Remove Method ( DataColumn )

System.Data Namespace   DataColumnCollection Class


Removes the specified DataColumn object from the collection.

[ VB ]
Overloads Public Sub Remove ( _
   ByVal column As DataColumn _
)

[ C# ]
public void Remove (
   DataColumn column
);

[ C++ ]
public: void Remove (
   DataColumn* column
);

[ JScript ]
public function Remove (
   column : DataColumn
);

Parameters

column
The DataColumn to remove.

Exceptions


Exception Type Condition
ArgumentNullException The column parameter is a null reference.
ArgumentException The column does not belong to this collection, or the column is part of a relationship, or another column's compute expression depends on this column.

Remarks

Use this overloaded version of the Remove method to remove a specified DataColumn object from the DataColumnCollection.

To remove a column at a specified index, use the RemoveAt method. You can also use the Clear method to remove all members of the collection at once.

The CollectionChanged event occurs when a column is successfully removed from the collection.

Example

The following example uses the CanRemove method to test whether the last column in a DataColumnCollection can be removed. If so, the Remove method is called to remove the column.

private void RemoveColumn ( DataTable myTable ) {
   // get the DataColumnCollection.
   DataColumnCollection myColumns = myTable.Columns;
   DataColumn col = myColumns [ myColumns.Count -1 ];
   if ( myColumns.CanRemove ( col ) ) myColumns.Remove ( col );
}
  C# VB

See Also

DataColumnCollection Members   DataColumnCollection.Remove Overload List   Contains   CanRemove   Item Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph