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 );
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. |
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.
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
TablesCollection Class | TablesCollection Members | System.Data Namespace | TablesCollection.Remove Overload List | IndexOf | Contains