DataTableCollection.IndexOf Metódus
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Lekéri az indexet a megadott DataTable objektum gyűjteményében.
Túlterhelések
| Name | Description |
|---|---|
| IndexOf(String, String) |
Lekéri az indexet a megadott DataTable objektum gyűjteményében. |
| IndexOf(DataTable) |
Lekéri a megadott DataTable objektum indexét. |
| IndexOf(String) |
Lekéri az indexet az DataTable objektum gyűjteményében a megadott névvel. |
IndexOf(String, String)
- Forrás:
- DataTableCollection.cs
- Forrás:
- DataTableCollection.cs
- Forrás:
- DataTableCollection.cs
- Forrás:
- DataTableCollection.cs
- Forrás:
- DataTableCollection.cs
Lekéri az indexet a megadott DataTable objektum gyűjteményében.
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
Paraméterek
Válaszok
A megadott névvel rendelkező nulla alapú index DataTable , vagy -1, ha a tábla nem létezik a gyűjteményben.
Példák
Az alábbi példa egy elnevezett tábla indexét adja vissza a 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
Megjegyzések
A tulajdonság használatával DataTable megadhatja az TableName objektum nevét.
Lásd még
A következőre érvényes:
IndexOf(DataTable)
- Forrás:
- DataTableCollection.cs
- Forrás:
- DataTableCollection.cs
- Forrás:
- DataTableCollection.cs
- Forrás:
- DataTableCollection.cs
- Forrás:
- DataTableCollection.cs
Lekéri a megadott DataTable objektum indexét.
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
Paraméterek
- table
- DataTable
A DataTable keresendő.
Válaszok
A tábla nulla alapú indexe, vagy -1, ha a tábla nem található a gyűjteményben.
Példák
Az alábbi példa a táblában lévő DataTableCollectiontáblák indexét adja vissza.
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
Megjegyzések
Az adott tábla pontos indexének meghatározásához használja a IndexOf metódust.
A hívás IndexOfelőtt tesztelheti egy tábla meglétét (index vagy név alapján megadva) a Contains metódus használatával.
Lásd még
A következőre érvényes:
IndexOf(String)
- Forrás:
- DataTableCollection.cs
- Forrás:
- DataTableCollection.cs
- Forrás:
- DataTableCollection.cs
- Forrás:
- DataTableCollection.cs
- Forrás:
- DataTableCollection.cs
Lekéri az indexet az DataTable objektum gyűjteményében a megadott névvel.
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
Paraméterek
- tableName
- String
A keresendő objektum neve DataTable .
Válaszok
A megadott névvel rendelkező nulla alapú index DataTable , vagy -1, ha a tábla nem létezik a gyűjteményben.
Példák
Az alábbi példa egy elnevezett tábla indexét adja vissza a 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
Megjegyzések
A tulajdonság használatával DataTable megadhatja az TableName objektum nevét.
Ez a módszer -1 ad vissza, ha két vagy több tábla neve azonos, de eltérő névterek. A hívás nem sikerül, ha a tábla nevének pontosan egy táblával való egyeztetése kétértelmű.