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.IndexOf (DataTable)

Returns the index of a specified DataTable.

[Visual Basic]
Overloads Overridable Public Function IndexOf( _
   ByVal table As DataTable _
) As Integer
[C#]
public virtual int IndexOf(
   DataTable table
);
[C++]
public: virtual int IndexOf(
   DataTable* table
);
[JScript]
public function IndexOf(
   table : DataTable
) : int;

Parameters

table
The DataTable to search for.

Return Value

The 0-based index of the table, or-1 if the table isn't found in the collection.

Remarks

Use the IndexOf method when it's necessary to know the exact index of a given table.

Before calling IndexOf, you can test for the existence of a table (specified by either index or name) using the Contains method.

Example [Visual Basic]

The following example returns the index of each table in the TablesCollection.

[Visual Basic]

Private Sub GetIndexes()
   Dim dSet As DataSet
   Dim tablesCol As TablesCollection
   ' Get the DataSet of a DataGrid.
   Set dSet = DataGrid1.DataGridTable.DataTable
   ' Get the TablesCollection through the Tables property.
   Set tablesCol = dSet.Tables
   Dim t As DataTable
   ' Get the index of each table in the collection.
   For Each t In tablesCol
      Debug.Print tablesCol.IndexOf(t)
   Next
End Sub

See Also

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