Compartilhar via


XmlForm.DataSources Propriedade

Definição

Obtém o DataSourceCollection objeto associado ao formulário.

public:
 abstract property Microsoft::Office::InfoPath::DataSourceCollection ^ DataSources { Microsoft::Office::InfoPath::DataSourceCollection ^ get(); };
public abstract Microsoft.Office.InfoPath.DataSourceCollection DataSources { get; }
member this.DataSources : Microsoft.Office.InfoPath.DataSourceCollection
Public MustOverride ReadOnly Property DataSources As DataSourceCollection

Valor da propriedade

Um DataSourceCollection que contém objetos DataSource associados ao formulário.

Exemplos

No exemplo de código a seguir, a propriedade DataSources da XmlForm classe é usada para definir uma referência à fonte de dados secundária "CityList".

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

No exemplo de código a seguir, que implementa um manipulador de eventos para um controle Button em um formulário, a propriedade DataSources do objeto XmlForm é usada para definir uma referência ao DataSourceCollection do formulário. O código percorre a coleção e exibe o índice posicional e o nome de cada objeto DataSource que ele contém.

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

Comentários

O objeto DataSourceCollection contém uma coleção de DataSource objetos que representam todas as fontes de dados externas (secundárias) associadas ao modelo de formulário. O objeto DataSourceCollection também contém um objeto DataSource que representa a main fonte de dados do formulário. Isso significa que os desenvolvedores terão duas maneiras de retornar o objeto DataSource que representa a fonte de dados main: usando DataSources[""] ou usando a MainDataSource propriedade.

This member can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.

This type or member can be accessed from code running in forms opened in Microsoft InfoPath Filler or in a Web browser.

Aplica-se a