This documentation is archived and is not being maintained.

Binding Data to Controls Overview

Note Required applications

The features in this topic are available only if you have the required applications installed.

For more information, see Features Available by Product Combination.

  • One of these development environments:

    VSTO 2005


    Visual Studio Team System

  • Microsoft Office 2003

Data binding works the same way in Microsoft Visual Studio 2005 Tools for the Microsoft Office System projects as it does in Windows Forms projects. For more information, see Data Binding and Windows Forms.

Displaying Data in Documents

You can use the Data Sources window to add data-bound controls to your documents easily, the same way you use it for Windows Forms. For more information, see Displaying Data Overview.

Visual Studio Tools for Office Controls

In addition to Windows Forms controls, Visual Studio Tools for Office includes Office-specific controls called host controls. You can bind data to these controls the same way you can bind data to Windows Forms controls. For more information, see Host Items and Host Controls Overview.

When you perform simple data binding to a host control, such as binding to a NamedRange or Bookmark, set the FormattingEnabled parameter to true to prevent the Change event from being raised twice. For example:


    <PropertyName>, <DataSource>, <DataMember>, true )

Updating Data That Is Bound to Host Controls

Data binding between a data source and a host control involves a two-way data update. In simple data binding, changes in the data source are reflected automatically in the host control, but changes in the host control require an explicit call to update the data source. The reason is that in some cases, changes in one data-bound field are not accepted unless they are accompanied by changes in another data-bound field. For example, you might have two fields, one for age and one for years of experience. Experience cannot exceed age. A user cannot update the age from 50 to 25 and then the experience from 30 to 10 unless he or she makes the changes at the same time. To solve this problem, fields with simple data binding are not updated until the updates are explicitly sent by code.

To update a data source from host controls that enable simple data binding, you must send updates to the data source using the WriteValue method. This is not needed when you do complex data binding using the ListObject control. In that case, changes are automatically sent to the associated data source without requiring additional code.

For more information, see How to: Update a Data Source with Data from a Host Control.

Increasing Performance in ListObject Controls

Reading an XML file into a data-bound ListObject control tends to be slower if you bind the control first, and then call ReadXml to fill the dataset. To improve performance, call ReadXml before you bind the control.

Disconnecting ListObject Controls from the Data Source

After you have filled a ListObject control with data by binding it to a data source, you can disconnect it so that modifications made to the data in the list object do not affect the data source. For more information, see How to: Fill ListObject Controls with Data.

See Also