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 (Int32)

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
);

Parameters

index
The index at which to remove a table.

Exceptions

Exception Type Condition
IndexOutOfRangeException The collection doesn't have a table at this index.

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 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

See Also

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