Compartilhar via


RemoteBindableComponent.DataBindings A propriedade (sistema de 2007)

Obtém o Binding objetos do componente.

Namespace:  Microsoft.VisualStudio.Tools.Office
Assembly:  Microsoft.Office.Tools.v9.0 (em Microsoft.Office.Tools.v9.0.dll)

Sintaxe

Public ReadOnly Property DataBindings As ControlBindingsCollection

Dim instance As RemoteBindableComponent
Dim value As ControlBindingsCollection

value = instance.DataBindings
public ControlBindingsCollection DataBindings { get; }

Valor de propriedade

Tipo: System.Windows.Forms.ControlBindingsCollection
A ControlBindingsCollection que contém o Binding objetos do componente.

Implementações

IBindableComponent.DataBindings

Comentários

Use esta propriedade para acessar o ControlBindingsCollection. Adicionando Binding objetos à coleção, você pode BIND qualquer propriedade do componente a uma propriedade de um objeto.

Exemplos

O exemplo de código a seguir adiciona uma única célula NamedRange controle (que deriva de RemoteBindableComponent), um DataSet com uma única coluna de nomes e um Button a planilha corrente. O exemplo usa o DataBindings propriedade para BIND a DataSet para o Value2 propriedade das NamedRange. Este exemplo de código faz parte de um exemplo de código maior fornecido para o RemoteBindableComponent classe.

Private namedRange1 As Microsoft.Office.Tools.Excel.NamedRange
PrivateWithEvents button1 As Microsoft.Office.Tools.Excel.Controls.Button
Private customerNames AsString() = _
    {"Reggie", "Sally", "Henry", "Christine"}
Private ds As DataSet

PrivateSub SetBindingContext()
    namedRange1 = Me.Controls.AddNamedRange(Me.Range("A1", _
        System.Type.Missing), "namedRange1")

    ' Create a button that scrolls through the data     ' displayed in the NamedRange.
    button1 = Me.Controls.AddButton(50, 20, 100, 20, "button1")
    button1.Text = "Display next item"
    ' Create a data table with one column.
    ds = New DataSet()
    Dim table As DataTable = ds.Tables.Add("Customers")
    Dim column1 AsNew DataColumn("Names", GetType(String))
    table.Columns.Add(column1)

    ' Add the names to the table.Dim row As DataRow
    Dim i AsIntegerFor i = 0 To customerNames.Length - 1
        row = table.NewRow()
        row("Names") = customerNames(i)
        table.Rows.Add(row)
    Next i

    ' Create a new Binding that links the Value2 property    ' of the NamedRange and the Names column.Dim binding1 AsNew Binding("Value2", ds, "Customers.Names", True)
    namedRange1.DataBindings.Add(binding1)
EndSub
private Microsoft.Office.Tools.Excel.NamedRange namedRange1;
private Microsoft.Office.Tools.Excel.Controls.Button button1;
privatestring[] customerNames = 
    { "Reggie", "Sally", "Henry", "Christine" };
private DataSet ds;

privatevoid SetBindingContext()
{
    namedRange1 = this.Controls.AddNamedRange(
        this.Range["A1", missing], "namedRange1");

    // Create a button that scrolls through the data // displayed in the NamedRange.
    button1 = this.Controls.AddButton(50, 20, 100, 20,
        "button1");
    button1.Text = "Display next item";
    button1.Click += new EventHandler(button1_Click);

    // Create a data table with one column.
    ds = new DataSet();
    DataTable table = ds.Tables.Add("Customers");
    DataColumn column1 = new DataColumn("Names", typeof(string));
    table.Columns.Add(column1);

    // Add the names to the table.
    DataRow row;
    for (int i = 0; i < customerNames.Length; i++)
    {
        row = table.NewRow();
        row["Names"] = customerNames[i];
        table.Rows.Add(row);
    }

    // Create a new Binding that links the Value2 property// of the NamedRange and the Names column.
    Binding binding1 = new Binding("Value2", ds, "Customers.Names", true);
    namedRange1.DataBindings.Add(binding1);
}

Permissões

Consulte também

Referência

RemoteBindableComponent Classe

Membros RemoteBindableComponent

Namespace Microsoft.VisualStudio.Tools.Office