DataTableCollection.IndexOf Metoda
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Pobiera indeks w kolekcji określonego DataTable obiektu.
Przeciążenia
IndexOf(String, String) |
Pobiera indeks w kolekcji określonego DataTable obiektu. |
IndexOf(DataTable) |
Pobiera indeks określonego DataTable obiektu. |
IndexOf(String) |
Pobiera indeks w kolekcji DataTable obiektu o określonej nazwie. |
IndexOf(String, String)
- Źródło:
- DataTableCollection.cs
- Źródło:
- DataTableCollection.cs
- Źródło:
- DataTableCollection.cs
Pobiera indeks w kolekcji określonego DataTable obiektu.
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
Parametry
Zwraca
Indeks DataTable oparty na zerze z określoną nazwą lub -1, jeśli tabela nie istnieje w kolekcji.
Przykłady
Poniższy przykład zwraca indeks nazwanej tabeli w tabeli 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
Uwagi
Należy określić nazwę DataTable obiektu przy użyciu TableName właściwości .
Zobacz też
Dotyczy
IndexOf(DataTable)
- Źródło:
- DataTableCollection.cs
- Źródło:
- DataTableCollection.cs
- Źródło:
- DataTableCollection.cs
Pobiera indeks określonego DataTable obiektu.
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
Parametry
- table
- DataTable
Element do wyszukania DataTable
.
Zwraca
Indeks na podstawie zera tabeli lub -1, jeśli tabela nie zostanie znaleziona w kolekcji.
Przykłady
Poniższy przykład zwraca indeks każdej tabeli w tabeli 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
Uwagi
IndexOf Użyj metody , aby określić dokładny indeks danej tabeli.
Przed wywołaniem IndexOfmetody można przetestować istnienie tabeli (określonej przez indeks lub nazwę) przy użyciu Contains metody .
Zobacz też
Dotyczy
IndexOf(String)
- Źródło:
- DataTableCollection.cs
- Źródło:
- DataTableCollection.cs
- Źródło:
- DataTableCollection.cs
Pobiera indeks w kolekcji DataTable obiektu o określonej nazwie.
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
Parametry
- tableName
- String
Nazwa DataTable
obiektu do wyszukania.
Zwraca
Indeks DataTable
oparty na zerze z określoną nazwą lub -1, jeśli tabela nie istnieje w kolekcji.
Przykłady
Poniższy przykład zwraca indeks nazwanej tabeli w tabeli 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
Uwagi
Należy określić nazwę DataTable
obiektu przy użyciu TableName właściwości .
Ta metoda zwraca wartość -1, gdy co najmniej dwie tabele mają taką samą nazwę, ale różne przestrzenie nazw. Wywołanie nie powiedzie się, jeśli podczas dopasowywania nazwy tabeli do dokładnie jednej tabeli występuje niejednoznaczność.
Zobacz też
Dotyczy
Opinia
https://aka.ms/ContentUserFeedback.
Dostępne już wkrótce: W 2024 r. będziemy stopniowo wycofywać zgłoszenia z serwisu GitHub jako mechanizm przesyłania opinii na temat zawartości i zastępować go nowym systemem opinii. Aby uzyskać więcej informacji, sprawdź:Prześlij i wyświetl opinię dla