DataTableCollection.IndexOf Metoda
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Získá index v kolekci zadaného DataTable objektu.
Přetížení
| Name | Description |
|---|---|
| IndexOf(String, String) |
Získá index v kolekci zadaného DataTable objektu. |
| IndexOf(DataTable) |
Získá index zadaného DataTable objektu. |
| IndexOf(String) |
Získá index v kolekci objektu DataTable se zadaným názvem. |
IndexOf(String, String)
- Zdroj:
- DataTableCollection.cs
- Zdroj:
- DataTableCollection.cs
- Zdroj:
- DataTableCollection.cs
- Zdroj:
- DataTableCollection.cs
- Zdroj:
- DataTableCollection.cs
Získá index v kolekci zadaného DataTable objektu.
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
Návraty
Index založený na nule zadaného DataTable názvu nebo -1, pokud tabulka v kolekci neexistuje.
Příklady
Následující příklad vrátí index pojmenované tabulky v objektu 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
Poznámky
Název objektu DataTable zadáte pomocí TableName vlastnosti.
Viz také
Platí pro
IndexOf(DataTable)
- Zdroj:
- DataTableCollection.cs
- Zdroj:
- DataTableCollection.cs
- Zdroj:
- DataTableCollection.cs
- Zdroj:
- DataTableCollection.cs
- Zdroj:
- DataTableCollection.cs
Získá index zadaného DataTable objektu.
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
Hledá se DataTable .
Návraty
Index tabulky založený na nule nebo -1, pokud se v kolekci nenajde tabulka.
Příklady
Následující příklad vrátí index každé tabulky v tabulce 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
Poznámky
Použijte metodu IndexOf k určení přesného indexu dané tabulky.
Před voláním IndexOfmůžete pomocí metody otestovat existenci tabulky (určenou indexem Contains nebo názvem).
Viz také
Platí pro
IndexOf(String)
- Zdroj:
- DataTableCollection.cs
- Zdroj:
- DataTableCollection.cs
- Zdroj:
- DataTableCollection.cs
- Zdroj:
- DataTableCollection.cs
- Zdroj:
- DataTableCollection.cs
Získá index v kolekci objektu DataTable se zadaným názvem.
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
Název objektu, který DataTable chcete vyhledat.
Návraty
Index založený na nule zadaného DataTable názvu nebo -1, pokud tabulka v kolekci neexistuje.
Příklady
Následující příklad vrátí index pojmenované tabulky v objektu 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
Poznámky
Název objektu DataTable zadáte pomocí TableName vlastnosti.
Tato metoda vrátí -1, pokud dvě nebo více tabulek mají stejný název, ale různé obory názvů. Volání není úspěšné, pokud při porovnávání názvu tabulky s přesně jednou tabulkou existuje nejednoznačnost.