NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

TablesCollection.Remove (DataTable)

Removes the specified table from the collection.

[Visual Basic]
Overloads Public Sub Remove( _
   ByVal table As DataTable _
)
[C#]
public void Remove(
   DataTable table
);
[C++]
public: void Remove(
   DataTable* table
);
[JScript]
public function Remove(
   table : DataTable
);

Parameters

table
The DataTable to remove.

Exceptions

Exception Type Condition
ArgumentNullException The table is a null reference (in Visual Basic Nothing).
ArgumentException The table doesn't belong to this collection.

-Or-

The table is part of a relationship.

Remarks

The OnCollectionChanged event occurs when a table is succesfully removed.

To determine if a given table exists and can be removed before invoking Remove, use the Contains and the CanRemove methods.

Example [Visual Basic]

The following example uses the CanRemove to test whether each table can be removed from a DataSet. If so, the Remove method is called to remove the table.

[Visual Basic]

Private Sub RemoveTables()
   Dim t As DataTable
   Dim dSet As DataSet
   ' Presuming a DataGrid is displaying more than one table, get its DataSet.
   Set dSet = DataGrid1.DataGridTable.DataTable.DataSet
   For each t in dSet.Tables
     If dSet.CanRemove t Then dSet.Remove t
   Next
End Sub

See Also

TablesCollection Class | TablesCollection Members | System.Data Namespace | TablesCollection.Remove Overload List | IndexOf | Contains