Share via


DataTableCollection.IndexOf Yöntem

Tanım

Belirtilen DataTable nesnenin koleksiyonundaki dizini alır.

Aşırı Yüklemeler

IndexOf(String, String)

Belirtilen DataTable nesnenin koleksiyonundaki dizini alır.

IndexOf(DataTable)

Belirtilen DataTable nesnenin dizinini alır.

IndexOf(String)

Belirtilen ada sahip nesne koleksiyonundaki DataTable dizini alır.

IndexOf(String, String)

Kaynak:
DataTableCollection.cs
Kaynak:
DataTableCollection.cs
Kaynak:
DataTableCollection.cs

Belirtilen DataTable nesnenin koleksiyonundaki dizini alır.

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

Parametreler

tableName
String

Aranacak nesnenin DataTable adı.

tableNamespace
String

Bakacak ad alanının DataTable adı.

Döndürülenler

Belirtilen ada sahip öğesinin DataTable sıfır tabanlı dizini veya koleksiyonda tablo yoksa -1.

Örnekler

Aşağıdaki örnek, içindeki adlandırılmış bir tablonun dizinini DataTableCollectiondöndürür.

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

Açıklamalar

özelliğini kullanarak TableName nesnenin DataTable adını belirtirsiniz.

Ayrıca bkz.

Şunlara uygulanır

IndexOf(DataTable)

Kaynak:
DataTableCollection.cs
Kaynak:
DataTableCollection.cs
Kaynak:
DataTableCollection.cs

Belirtilen DataTable nesnenin dizinini alır.

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

Parametreler

table
DataTable

DataTable Aranacak.

Döndürülenler

Tablonun sıfır tabanlı dizini veya tablo koleksiyonda bulunamazsa -1.

Örnekler

Aşağıdaki örnek içindeki her tablonun dizinini DataTableCollectiondöndürür.

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

Açıklamalar

IndexOf Belirli bir tablonun tam dizinini belirlemek için yöntemini kullanın.

çağrısı IndexOfyapmadan önce yöntemini kullanarak Contains bir tablonun varlığını (dizin veya adla belirtilen) test edebilirsiniz.

Ayrıca bkz.

Şunlara uygulanır

IndexOf(String)

Kaynak:
DataTableCollection.cs
Kaynak:
DataTableCollection.cs
Kaynak:
DataTableCollection.cs

Belirtilen ada sahip nesne koleksiyonundaki DataTable dizini alır.

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

Parametreler

tableName
String

Aranacak nesnenin DataTable adı.

Döndürülenler

Belirtilen ada sahip öğesinin DataTable sıfır tabanlı dizini veya koleksiyonda tablo yoksa -1.

Örnekler

Aşağıdaki örnek, içindeki adlandırılmış bir tablonun dizinini DataTableCollectiondöndürür.

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

Açıklamalar

özelliğini kullanarak TableName nesnenin DataTable adını belirtirsiniz.

bu yöntem, iki veya daha fazla tablo aynı ada ancak farklı ad alanlarına sahip olduğunda -1 döndürür. Bir tablo adı tam olarak tek bir tabloyla eşleştirilirken herhangi bir belirsizlik olduğunda çağrı başarılı olmaz.

Ayrıca bkz.

Şunlara uygulanır