RemoteBindableComponent.DataBindings プロパティ (2007 System)

更新 : 2007 年 11 月

コンポーネントの Binding オブジェクトを取得します。

名前空間 :  Microsoft.VisualStudio.Tools.Office
アセンブリ :  Microsoft.Office.Tools.v9.0 (Microsoft.Office.Tools.v9.0.dll 内)

構文

'宣言
Public ReadOnly Property DataBindings As ControlBindingsCollection
'使用
Dim instance As RemoteBindableComponent
Dim value As ControlBindingsCollection

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

プロパティ値

型 : System.Windows.Forms.ControlBindingsCollection

コンポーネントの Binding オブジェクトが含まれる ControlBindingsCollection

実装

IBindableComponent.DataBindings

解説

このプロパティは、ControlBindingsCollection にアクセスする場合に使用します。このコレクションに Binding オブジェクトを追加すると、コンポーネントの任意のプロパティをオブジェクトのプロパティにバインドできます。

1 つのセル NamedRange コントロール (RemoteBindableComponent から派生するクラス)、名前の列 DataSet、および Button を現在のワークシートに追加するコード例を次に示します。このコード例では、DataBindings プロパティを使用して、NamedRangeValue2 プロパティに DataSet をバインドします。次のコード例は、RemoteBindableComponent クラス用のより大きなコード例の一部です。

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

Private Sub 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 As New DataColumn("Names", GetType(String))
    table.Columns.Add(column1)

    ' Add the names to the table.
    Dim row As DataRow
    Dim i As Integer
    For 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 As New Binding("Value2", ds, "Customers.Names", True)
    namedRange1.DataBindings.Add(binding1)
End Sub
private Microsoft.Office.Tools.Excel.NamedRange namedRange1;
private Microsoft.Office.Tools.Excel.Controls.Button button1;
private string[] customerNames = 
    { "Reggie", "Sally", "Henry", "Christine" };
private DataSet ds;

private void 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);
}

アクセス許可

  • 直前の呼び出し元に対する完全な信頼。このメンバは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

RemoteBindableComponent クラス

RemoteBindableComponent メンバ

Microsoft.VisualStudio.Tools.Office 名前空間