DataTableCollection.Item[] Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene l'oggetto specificato DataTable dall'insieme.
Overload
| Nome | Descrizione |
|---|---|
| Item[Int32] |
Ottiene l'oggetto DataTable in corrispondenza dell'indice specificato. |
| Item[String] |
Ottiene l'oggetto DataTable con il nome specificato. |
| Item[String, String] |
Ottiene l'oggetto DataTable con il nome specificato nello spazio dei nomi specificato. |
Item[Int32]
Ottiene l'oggetto DataTable in corrispondenza dell'indice specificato.
public:
property System::Data::DataTable ^ default[int] { System::Data::DataTable ^ get(int index); };
public System.Data.DataTable this[int index] { get; }
member this.Item(int) : System.Data.DataTable
Default Public ReadOnly Property Item(index As Integer) As DataTable
Parametri
Valore della proprietà
Oggetto DataTable con l'indice specificato; in caso contrario null , se l'oggetto DataTable non esiste.
Eccezioni
Il valore di indice è maggiore del numero di elementi nell'insieme.
Esempio
Nell'esempio seguente viene recuperato un oggetto DataTable in base al relativo indice.
private void GetDataTableByIndex()
{
// presuming a DataGrid is displaying more than one table, get its DataSet.
DataSet thisDataSet = (DataSet)DataGrid1.DataSource;
// Get the DataTableCollection.
DataTableCollection tablesCollection = thisDataSet.Tables;
// Iterate through the collection to get each table name.
for (int i = 0; i < tablesCollection.Count; i++)
Console.WriteLine(tablesCollection[i].TableName);
}
Private Sub GetDataTableByIndex()
' Presuming a DataGrid is displaying more than one table, get its DataSet.
Dim thisDataSet As DataSet = CType(DataGrid1.DataSource, DataSet)
' Get the DataTableCollection.
Dim tablesCollection As DataTableCollection = thisDataSet.Tables
' Iterate through the collection to get each table name.
Dim i As Integer
For i = 0 To tablesCollection.Count - 1
Console.WriteLine(tablesCollection(i).TableName)
Next
End Sub
Commenti
Utilizzare il Contains metodo per determinare se esiste una tabella con un indice specifico.
Se si dispone del nome di una tabella, ma non del relativo indice, utilizzare il IndexOf metodo per restituire l'indice.
Vedi anche
Si applica a
Item[String]
Ottiene l'oggetto DataTable con il nome specificato.
public:
property System::Data::DataTable ^ default[System::String ^] { System::Data::DataTable ^ get(System::String ^ name); };
public System.Data.DataTable this[string name] { get; }
member this.Item(string) : System.Data.DataTable
Default Public ReadOnly Property Item(name As String) As DataTable
Parametri
- name
- String
Nome dell'oggetto DataTable da trovare.
Valore della proprietà
Oggetto DataTable con il nome specificato; in caso contrario null , se l'oggetto DataTable non esiste.
Esempio
Nell'esempio seguente viene recuperata una singola tabella in base al nome dall'oggetto DataTableCollection.
private void GetTableByName()
{
// Presuming a DataGrid is displaying more than one table, get its DataSet.
DataSet thisDataSet = (DataSet)DataGrid1.DataSource;
// Get the DataTableCollection.
DataTableCollection tablesCollection = thisDataSet.Tables;
// Get a specific table by name.
DataTable table = tablesCollection["Suppliers"];
Console.WriteLine(table.TableName);
}
Private Sub GetTableByName()
' Presuming a DataGrid is displaying more than one table,
' get its DataSet.
Dim thisDataSet As DataSet = CType(DataGrid1.DataSource, DataSet)
' Get the DataTableCollection.
Dim tablesCollection As DataTableCollection = thisDataSet.Tables
' Get a specific table by name.
Dim table As DataTable = tablesCollection("Suppliers")
Console.WriteLine(table.TableName)
End Sub
Commenti
Se esiste un DataTable nome che corrisponde al caso della stringa di ricerca, viene restituito . In caso contrario, viene eseguita una ricerca senza distinzione tra maiuscole e minuscole e viene restituito un DataTable nome corrispondente a questa ricerca.
Utilizzare il Contains metodo per determinare se esiste una tabella con un nome o un indice specifico.
Si applica a
Item[String, String]
Ottiene l'oggetto DataTable con il nome specificato nello spazio dei nomi specificato.
public:
property System::Data::DataTable ^ default[System::String ^, System::String ^] { System::Data::DataTable ^ get(System::String ^ name, System::String ^ tableNamespace); };
public System.Data.DataTable this[string name, string tableNamespace] { get; }
member this.Item(string * string) : System.Data.DataTable
Default Public ReadOnly Property Item(name As String, tableNamespace As String) As DataTable
Parametri
- name
- String
Nome dell'oggetto DataTable da trovare.
Valore della proprietà
Oggetto DataTable con il nome specificato; in caso contrario null , se l'oggetto DataTable non esiste.