Condividi tramite


DataTableCollection.IndexOf Metodo

Definizione

Ottiene l'indice nell'insieme dell'oggetto specificato DataTable .

Overload

Nome Descrizione
IndexOf(String, String)

Ottiene l'indice nell'insieme dell'oggetto specificato DataTable .

IndexOf(DataTable)

Ottiene l'indice dell'oggetto specificato DataTable .

IndexOf(String)

Ottiene l'indice nell'insieme dell'oggetto DataTable con il nome specificato.

IndexOf(String, String)

Origine:
DataTableCollection.cs
Origine:
DataTableCollection.cs
Origine:
DataTableCollection.cs
Origine:
DataTableCollection.cs
Origine:
DataTableCollection.cs

Ottiene l'indice nell'insieme dell'oggetto specificato 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

Parametri

tableName
String

Nome dell'oggetto DataTable da cercare.

tableNamespace
String

Nome dello DataTable spazio dei nomi da cercare.

Restituisce

Indice in base zero dell'oggetto DataTable con il nome specificato oppure -1 se la tabella non esiste nell'insieme.

Esempio

Nell'esempio seguente viene restituito l'indice di una tabella denominata in 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

Commenti

Specificare il nome dell'oggetto DataTable utilizzando la TableName proprietà .

Vedi anche

Si applica a

IndexOf(DataTable)

Origine:
DataTableCollection.cs
Origine:
DataTableCollection.cs
Origine:
DataTableCollection.cs
Origine:
DataTableCollection.cs
Origine:
DataTableCollection.cs

Ottiene l'indice dell'oggetto specificato 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

Parametri

table
DataTable

Oggetto DataTable da cercare.

Restituisce

Indice in base zero della tabella o -1 se la tabella non viene trovata nell'insieme.

Esempio

Nell'esempio seguente viene restituito l'indice di ogni tabella nell'oggetto 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

Commenti

Utilizzare il IndexOf metodo per determinare l'indice esatto di una determinata tabella.

Prima di chiamare IndexOf, è possibile verificare l'esistenza di una tabella (specificata da index o name) usando il Contains metodo .

Vedi anche

Si applica a

IndexOf(String)

Origine:
DataTableCollection.cs
Origine:
DataTableCollection.cs
Origine:
DataTableCollection.cs
Origine:
DataTableCollection.cs
Origine:
DataTableCollection.cs

Ottiene l'indice nell'insieme dell'oggetto DataTable con il nome specificato.

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

Parametri

tableName
String

Nome dell'oggetto DataTable da cercare.

Restituisce

Indice in base zero dell'oggetto DataTable con il nome specificato oppure -1 se la tabella non esiste nell'insieme.

Esempio

Nell'esempio seguente viene restituito l'indice di una tabella denominata in 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

Commenti

Specificare il nome dell'oggetto DataTable utilizzando la TableName proprietà .

Questo metodo restituisce -1 quando due o più tabelle hanno lo stesso nome ma spazi dei nomi diversi. La chiamata non riesce se si verifica un'ambiguità quando si associa un nome di tabella esattamente a una tabella.

Vedi anche

Si applica a