This documentation is archived and is not being maintained.

BindableComponent Class

Visual Studio 2005

Provides a default implementation of the IBindableComponent interface.

Namespace: Microsoft.VisualStudio.Tools.Applications.Runtime
Assembly: Microsoft.VisualStudio.Tools.Applications.Runtime (in

public abstract class BindableComponent : Component, IBindableComponent, IComponent, IDisposable

Host controls that can be bound to data inherit from this type. It is not intended to be used directly from your code.

The following code example adds a single cell NamedRange (which derives from BindableComponent), a DataSet with a single column of names, and a Button to the current worksheet. The example uses the DataBindings property to bind the DataSet to the Value2 property of the NamedRange. When the Button is clicked, the example uses the BindingContext property to display the next name in the NamedRange.

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.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));

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

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

    // Add the DataSet to the bindings of the NamedRange.

// Displays the next data item in the NamedRange.
void button1_Click(object sender, EventArgs e)
    if (namedRange1.BindingContext != null)
        BindingManagerBase bindingManager1 =
            namedRange1.BindingContext[ds, "Customers"];

        // Display the next item.
        if (bindingManager1.Position < bindingManager1.Count - 1)

        // Display the first item.
            bindingManager1.Position = 0;


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.