Compartir por


DataTableCollection.IndexOf Método

Definición

Obtiene el índice de la colección del objeto especificado DataTable .

Sobrecargas

Nombre Description
IndexOf(String, String)

Obtiene el índice de la colección del objeto especificado DataTable .

IndexOf(DataTable)

Obtiene el índice del objeto especificado DataTable .

IndexOf(String)

Obtiene el índice de la colección del DataTable objeto con el nombre especificado.

IndexOf(String, String)

Source:
DataTableCollection.cs
Source:
DataTableCollection.cs
Source:
DataTableCollection.cs
Source:
DataTableCollection.cs
Source:
DataTableCollection.cs

Obtiene el índice de la colección del objeto especificado DataTable .

public:
 int IndexOf(System::String ^ tableName, System::String ^ tableNamespace);
public int IndexOf(string tableName, string tableNamespace);
member this.IndexOf : string * string -> int
Public Function IndexOf (tableName As String, tableNamespace As String) As Integer

Parámetros

tableName
String

Nombre del DataTable objeto que se va a buscar.

tableNamespace
String

Nombre del espacio de nombres en el DataTable que se va a buscar.

Devoluciones

Índice de base cero de DataTable con el nombre especificado o -1 si la tabla no existe en la colección.

Ejemplos

En el ejemplo siguiente se devuelve el índice de una tabla con nombre en .DataTableCollection

private void GetIndexes()
{
    // Get the DataSet of a DataGrid.
    DataSet thisDataSet = (DataSet)DataGrid1.DataSource;

    // Get the DataTableCollection through the Tables property.
    DataTableCollection tables = thisDataSet.Tables;

    // Get the index of the table named "Authors", if it exists.
    if (tables.Contains("Authors"))
        System.Diagnostics.Debug.WriteLine(tables.IndexOf("Authors"));
}
Private Sub GetIndexes()
   ' Get the DataSet of a DataGrid.
   Dim thisDataSet As DataSet = CType(DataGrid1.DataSource, DataSet)

   ' Get the DataTableCollection through the Tables property.
   Dim tables As DataTableCollection = thisDataSet.Tables

   ' Get the index of the table named "Authors", if it exists.
   If tables.Contains("Authors") Then
      System.Diagnostics.Debug.WriteLine(tables.IndexOf("Authors"))
   End If
End Sub

Comentarios

Especifique el nombre del DataTable objeto mediante la TableName propiedad .

Consulte también

Se aplica a

IndexOf(DataTable)

Source:
DataTableCollection.cs
Source:
DataTableCollection.cs
Source:
DataTableCollection.cs
Source:
DataTableCollection.cs
Source:
DataTableCollection.cs

Obtiene el índice del objeto especificado DataTable .

public:
 int IndexOf(System::Data::DataTable ^ table);
public:
 virtual int IndexOf(System::Data::DataTable ^ table);
public int IndexOf(System.Data.DataTable? table);
public int IndexOf(System.Data.DataTable table);
public virtual int IndexOf(System.Data.DataTable table);
member this.IndexOf : System.Data.DataTable -> int
abstract member IndexOf : System.Data.DataTable -> int
override this.IndexOf : System.Data.DataTable -> int
Public Function IndexOf (table As DataTable) As Integer
Public Overridable Function IndexOf (table As DataTable) As Integer

Parámetros

table
DataTable

que DataTable se va a buscar.

Devoluciones

Índice de base cero de la tabla o -1 si la tabla no se encuentra en la colección.

Ejemplos

En el ejemplo siguiente se devuelve el índice de cada tabla de DataTableCollection.

private void GetIndexes()
{
    // Get the DataSet of a DataGrid.
    DataSet thisDataSet = (DataSet)DataGrid1.DataSource;

    // Get the DataTableCollection through the Tables property.
    DataTableCollection tables = thisDataSet.Tables;

    // Get the index of each table in the collection.
    foreach (DataTable table in tables)
        System.Diagnostics.Debug.WriteLine(tables.IndexOf(table));
}
Private Sub GetIndexes()
    ' Get the DataSet of a DataGrid.
    Dim thisDataSet As DataSet = CType(DataGrid1.DataSource, DataSet)

    ' Get the DataTableCollection through the Tables property.
    Dim tables As DataTableCollection = thisDataSet.Tables
    Dim table As DataTable

    ' Get the index of each table in the collection.
    For Each table In tables
       System.Diagnostics.Debug.WriteLine(tables.IndexOf(table))
    Next
End Sub

Comentarios

Use el IndexOf método para determinar el índice exacto de una tabla determinada.

Antes de llamar a IndexOf, puede probar la existencia de una tabla (especificada por índice o nombre) mediante el Contains método .

Consulte también

Se aplica a

IndexOf(String)

Source:
DataTableCollection.cs
Source:
DataTableCollection.cs
Source:
DataTableCollection.cs
Source:
DataTableCollection.cs
Source:
DataTableCollection.cs

Obtiene el índice de la colección del DataTable objeto con el nombre especificado.

public:
 int IndexOf(System::String ^ tableName);
public:
 virtual int IndexOf(System::String ^ tableName);
public int IndexOf(string? tableName);
public int IndexOf(string tableName);
public virtual int IndexOf(string tableName);
member this.IndexOf : string -> int
abstract member IndexOf : string -> int
override this.IndexOf : string -> int
Public Function IndexOf (tableName As String) As Integer
Public Overridable Function IndexOf (tableName As String) As Integer

Parámetros

tableName
String

Nombre del DataTable objeto que se va a buscar.

Devoluciones

Índice de base cero de DataTable con el nombre especificado o -1 si la tabla no existe en la colección.

Ejemplos

En el ejemplo siguiente se devuelve el índice de una tabla con nombre en .DataTableCollection

private void GetIndexes()
{
    // Get the DataSet of a DataGrid.
    DataSet thisDataSet = (DataSet)DataGrid1.DataSource;

    // Get the DataTableCollection through the Tables property.
    DataTableCollection tables = thisDataSet.Tables;

    // Get the index of the table named "Authors", if it exists.
    if (tables.Contains("Authors"))
        System.Diagnostics.Debug.WriteLine(tables.IndexOf("Authors"));
}
Private Sub GetIndexes()
   ' Get the DataSet of a DataGrid.
   Dim thisDataSet As DataSet = CType(DataGrid1.DataSource, DataSet)

   ' Get the DataTableCollection through the Tables property.
   Dim tables As DataTableCollection = thisDataSet.Tables

   ' Get the index of the table named "Authors", if it exists.
   If tables.Contains("Authors") Then
      System.Diagnostics.Debug.WriteLine(tables.IndexOf("Authors"))
   End If
End Sub

Comentarios

Especifique el nombre del DataTable objeto mediante la TableName propiedad .

Este método devuelve -1 cuando dos o más tablas tienen el mismo nombre, pero espacios de nombres diferentes. La llamada no se realiza correctamente si hay alguna ambigüedad al hacer coincidir un nombre de tabla con exactamente una tabla.

Consulte también

Se aplica a