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;
The 0-based index of the table, or-1 if the table isn't found in the collection.
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.
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
TablesCollection Class | TablesCollection Members | System.Data Namespace | TablesCollection.IndexOf Overload List | IndexOf | TableName | Remove