Condividi tramite


Proprietà XmlForm.DataSources

Ottiene l'oggetto DataSourceCollection associato al modulo.

Spazio dei nomi: Microsoft.Office.InfoPath
Assembly: Microsoft.Office.InfoPath (in microsoft.office.infopath.dll)

Sintassi

Public MustOverride ReadOnly Property DataSources As DataSourceCollection

Dim instance As XmlForm
Dim value As DataSourceCollection

value = instance.DataSources
public abstract DataSourceCollection DataSources { get; }

Valore proprietà

Insieme DataSourceCollection che contiene eventuali oggetti DataSource associati al modulo.

Osservazioni

L'oggetto DataSourceCollection contiene un insieme di oggetti DataSource che rappresentano tutte le origini dati esterne, o secondarie, associate al modello di modulo. L'oggetto DataSourceCollection contiene inoltre un oggetto DataSource che rappresenta l'origine dati principale del modulo. Questo significa che gli sviluppatori dispongono sempre di due modi per restituire l'oggetto DataSource che rappresenta l'origine dati principale, ovvero tramite l'utilizzo di DataSourceCollection[""] o della proprietà MainDataSource.

Nota:

La proprietà DataSources offre funzionalità simili a quelle della proprietà DataObjects dell'oggetto XDocument del modello a oggetti COM o script e della proprietà DataObjects dell'interfaccia _XDocument2 del modello a oggetti in codice gestito compatibile con InfoPath 2003.

Possono accedere a questo membro solo moduli eseguiti nello stesso dominio del modulo aperto oppure moduli a cui sono state concesse autorizzazioni tra domini.

A questo tipo o membro può accedere solo il codice in esecuzione in moduli aperti in Microsoft Office InfoPath 2007 o in un browser.

Esempio

Nell'esempio seguente viene utilizzata la proprietà DataSources della classe XmlForm per impostare un riferimento all'origine dati secondaria "CityList".

DataSource myDataSource = this.DataSources["CityList"];
Dim myDataSource As DataSource = Me.DataSources("CityList")

Nell'esempio seguente, che implementa un gestore eventi per un controllo Pulsante in un modulo, viene utilizzata la proprietà DataSources dell'oggetto XmlForm per impostare un riferimento all'insieme DataSourceCollection del modulo. Viene quindi eseguito un ciclo nell'insieme e vengono visualizzati l'indice di posizione e il nome di ogni oggetto DataSource contenuto nell'insieme.

public void CTRL1_Clicked(object sender, ClickedEventArgs e)
{
   // Set a reference to the DataSources collection.
   DataSourceCollection myDataSources = this.DataSources;

   // Loop through the collection and display the name
   // of each DataSource object that it contains.
   for (int i = 0; i < myDataSources.Count; i++)
   {
      MessageBox.Show("Data source " + i + ": " + 
         myDataSources[i].Name);
   }
}
Public Sub CTRL1_Clicked(ByVal sender As Object, _
   ByVal e As ClickedEventArgs)
   ' Set a reference to the DataSources collection.
   Dim myDataSources As DataSourceCollection = Me.DataSources

   ' Loop through the collection and display the name
   ' of each DataSource object that it contains.
   Dim i As Integer
   For i = 0 To myDataSources.Count - 1
      MessageBox.Show("Data source " & i & ": " _
         & myDataSources(i).Name)
   Next
End Sub

Vedere anche

Riferimenti

Classe XmlForm
Membri XmlForm
Spazio dei nomi Microsoft.Office.InfoPath