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

Gets the table specified by its index.

[C#] In C#, this member is the indexer for the TablesCollection class.

[Visual Basic]
Overloads Public Default ReadOnly Property Item( _
   ByVal index As Integer _
) As DataTable
[C#]
public DataTable this[
   int index
] {get;}
[C++]
public: __property DataTable* get_Item(
   int index
);
[JScript]
returnValue = TablesCollectionObject.Item(index);
-or-
returnValue = TablesCollectionObject(index);

[JScript] In JScript, you can use the default indexed properties defined by a type, but you cannot explicitly define your own. However, specifying the expando attribute on a class automatically provides a default indexed Item property whose type is Object and whose index type is String.

Arguments [JScript]

index
The zero-based index of the DataTable being sought.

Parameters [Visual Basic, C#, C++]

index
The zero-based index of the DataTable being sought.

Property Value

A DataTable.

Exceptions

Exception Type Condition
IndexOutOfRangeException The index doesn't exist in the collection.

Remarks

The Contains method can be used to determine if a table with a specified index exists.

If you have the name of a table, but not its index, use the IndexOf method to return the table's index.

Example [Visual Basic]

The following example retrieves a DataTable by its index.

[Visual Basic]

Private Sub GetDataTableByIndex()
   Dim tablesCol As TablesCollection
   Dim dSet As DataSet
   ' Presuming a DataGrid is displaying more than one table, get its DataSet.
   Set dSet = DataGrid1.DataGridTable.DataTable.DataSet
   ' Get the TablesCollection.
   Set tablesCol = dSet.Tables
   ' Iterate through the collection to get each table name.
   Dim i As Integer
   For i = 0 To tablesCol.Count - 1
      Console.WriteLine(TableCol(i).TableName)
   Next
End Sub

See Also

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