Binding Constructor (String, Object, String)


Initializes a new instance of the Binding class that simple-binds the indicated control property to the specified data member of the data source.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public Binding(
	string propertyName,
	object dataSource,
	string dataMember


Type: System.String

The name of the control property to bind.

Type: System.Object

An Object that represents the data source.

Type: System.String

The property or list to bind to.

Exception Condition

propertyName is neither a valid property of a control nor an empty string ("").


The property given by propertyName does not exist on the control.

You can specify an instance of any of the following classes for the data source:

See the Binding class for more information about creating the dataMember string.

When you create a binding to a control's property, the new Binding inspects the events exposed by the bound control and attaches to two particular events:

If you attempt to bind to a property that does not exist, an ArgumentException will be thrown when the Binding is added to the control's Control.DataBindings collection.

The following code example binds a TextBox control to a table column in a DataSet named myDataSet. The example requires that you have declared myDataSet in the declarations section of the module.

private void CreateDataSet()
   myDataSet = new DataSet("myDataSet");
   /* Populates the DataSet with tables, relations, and 
      constraints. */

private void BindTextBoxToDataSet()
   /* Binds a TextBox control to a DataColumn named
   CompanyName in the DataTable named Suppliers. */
   ("Text", myDataSet, "Suppliers.CompanyName");

.NET Framework
Available since 1.1
Return to top