Removes the table with a specified name from the collection.
[Visual Basic] Overloads Public Sub Remove( _ ByVal name As String _ ) [C#] public void Remove( string name ); [C++] public: void Remove( String* name ); [JScript] public function Remove( name : String );
Exception Type | Condition |
---|---|
IndexOutOfRangeException | The collection doesn't have a table at this index. |
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 Contains and CanRemove to test whether a named table exists and can be removed. If so, the Remove method is called to remove the table.
[Visual Basic]
Private Sub RemoveTables() Dim tablesCol As TablesCollection Dim dSet As DataSet ' Set the name of the table to test for and remove. Dim strName As Integer: strName = "Suppliers" ' Presuming a DataGrid is displaying more than one table, get its DataSet. Set dSet = DataGrid1.DataGridTable.DataTable.DataSet Set tablesCol = dSet.Tables If tablesCol.Contains(strName) And tablesCol.CanRemove(strName) Then tablesCol.Remove strName End If End Sub
TablesCollection Class | TablesCollection Members | System.Data Namespace | TablesCollection.Remove Overload List | IndexOf | Contains