Removes the table at the given index from the collection
[Visual Basic] Overloads Public Sub Remove( _ ByVal index As Integer _ ) [C#] public void Remove( int index ); [C++] public: void Remove( int index ); [JScript] public function Remove( index : int );
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 table with the index 10 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 index of the table to test for and remove. Dim tblIndex As Integer: tblIndex = 10 ' 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(tblIndex) And tablesCol.CanRemove(tblIndex) Then tablesCol.Remove tblIndex End If End Sub
TablesCollection Class | TablesCollection Members | System.Data Namespace | TablesCollection.Remove Overload List | IndexOf | Contains