System.Windows.Forms
1.0.5000.0
2.0.0.0
System.Object
System.Collections.ICollection
System.ComponentModel.DefaultEvent("CollectionChanged")
Each Windows Form has at least one object that manages the objects for the form. Because the class is abstract, the return type of the property is either a or a . If the data source is an object that can return only a single property (instead of a list of objects), the is a . For example, if you specify a as the data source, a is returned. On the other hand, if the data source is an object that implements or , a is returned.
For each data source on a Windows Form, there is a single or . Because there may be multiple data sources associated with a Windows Form, the enables you to retrieve any particular associated with a data source.
When using the property, the creates a new if one does not already exist. This can lead to some confusion, as the returned object may not manage the list (or any list) that you intend. To prevent returning an invalid , use the method to determine if the intended already exists.
If you use a container control, such as a , , or , to contain data-bound controls, you can create a for just that container control and its controls. Then, each part of your form can be managed by its own . See the constructor for more information about creating multiple objects for the same data source.
If you add a control to a form and bind it to a column of a table in a dataset, the control communicates with the of that form. The , in turn, talks to the specific for that data association. If you queried the Position property of the , it would report the current record for the binding of that control. In the following code example, a control is bound to the FirstName column of a Customers table on the dataSet1 dataset through the for the form it is on.
TextBox1.DataBindings.Add("Text", dataSet1, "Customers.FirstName")
textBox1.DataBindings.Add("Text", dataSet1, "Customers.FirstName");
textBox1->DataBindings->Add("Text", dataSet1, "Customers.FirstName");
You can add a second control (TextBox2) to the form and bind it to the LastName column of the Customers table in the same dataset. The is aware of the first binding (TextBox1 to Customers.FirstName), so it would use the same , as both text boxes are bound to the same dataset (DataSet1).
TextBox2.DataBindings.Add("Text", dataSet1, "Customers.LastName")
textBox2.DataBindings.Add("Text", dataSet1, "Customers.LastName");
textBox2->DataBindings->Add("Text", dataSet1, "Customers.LastName");
If you bind TextBox2 to a different dataset, the creates and manages a second .
It is important to be consistent about how you set the and properties; otherwise, the creates multiple currency managers for the same dataset, which results in errors. The following code example shows a few ways to set the properties and their associated objects. You can set the properties using either of the following methods, as long as you are consistent throughout your code.
ComboBox1.DataSource = DataSet1
ComboBox1.DisplayMember = "Customers.FirstName"
Me.BindingContext(dataSet1, "Customers").Position = 1
comboBox1.DataSource = DataSet1;
comboBox1.DisplayMember = "Customers.FirstName";
this.BindingContext[dataSet1, "Customers"].Position = 1;
comboBox1->DataSource = dataSet1;
comboBox1->DisplayMember = "Customers.FirstName";
this->BindingContext->get_Item(dataSet1, "Customers")->Position = 1;
ComboBox1.DataSource = DataSet1.Customers
ComboBox1.DisplayMember = "FirstName"
Me.BindingContext(dataSet1.Customers).Position = 1
comboBox1.DataSource = DataSet1.Customers;
comboBox1.DisplayMember = "FirstName";
this.BindingContext[dataSet1.Customers].Position = 1;
comboBox1->DataSource = dataSet1->Customers;
comboBox1->DisplayMember = "FirstName";
this->BindingContext->get_Item(dataSet1->Customers)->Position = 1;
Most Windows Forms applications bind through a . The component encapsulates a and exposes the programming interface. When using a for binding, you should use the members exposed by the to manipulate "currency" (that is, Position) rather than go through the .
Manages the collection of objects for any object that inherits from the class.
Constructor
If you want to have multiple instances for the same data source, create a new and set it to the property of an object that inherits from the class. For example, if you have two objects (from two different objects), you can set the properties of each to different values. This causes each set of data-bound controls to display different values from the same data source.
Initializes a new instance of the class.
1.0.5000.0
2.0.0.0
Method
1.0.5000.0
2.0.0.0
System.Void
To be added.
Adds the associated with a specific data source to the collection.
The associated with the .
The to add.
Method
System.Void
To be added.
Adds the associated with a specific data source to the collection.
The object associated with the .
The to add.
1.0.5000.0
2.0.0.0
Method
1.0.5000.0
2.0.0.0
System.Void
To be added.
Clears the collection of any objects.
Method
System.Void
To be added.
Clears the collection.
1.0.5000.0
2.0.0.0
Event
System.ComponentModel.CollectionChangeEventHandler
The event is obsolete and always raises a when handled. For more information about handling events, see Consuming Events.
Always raises a when handled.
1.0.5000.0
2.0.0.0
System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)
System.ComponentModel.Browsable(false)
Method
System.Boolean
See the class for a list of possible data sources and information about creating bindings between controls and data sources.
See the property for information about returning a using only a data source.
Gets a value indicating whether the contains the associated with the specified data source.
true if the contains the specified ; otherwise, false.
An that represents the data source.
1.0.5000.0
2.0.0.0
Method
System.Boolean
See the class for a list of possible data sources and for information about creating bindings between controls and data sources.
See the property for information about returning a using a data source and data member.
Gets a value indicating whether the contains the associated with the specified data source and data member.
true if the contains the specified ; otherwise, false.
An that represents the data source.
The information needed to resolve to a specific .
1.0.5000.0
2.0.0.0
Property
System.Boolean
To be added.
This property is derived from , and is overridden to always return false.
Gets a value indicating whether the collection is read-only.
1.0.5000.0
2.0.0.0
Property
System.Windows.Forms.BindingManagerBase
To be added.
To be added.
To be added.
To be added.
1.0.5000.0
2.0.0.0
Property
System.Windows.Forms.BindingManagerBase
To be added.
To be added.
To be added.
To be added.
To be added.
1.0.5000.0
2.0.0.0
Method
System.Void
Raising an event invokes the event handler through a delegate. For more information, see Raising an Event.
The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
Raises the event.
A that contains the event data.
1.0.5000.0
2.0.0.0
Method
1.0.5000.0
2.0.0.0
System.Void
To be added.
Deletes the associated with the specified data source.
The data source associated with the to remove.
Method
System.Void
To be added.
Removes the associated with the specified data source.
The data source associated with the to remove.
1.0.5000.0
2.0.0.0
Method
1.0.5000.0
2.0.0.0
System.Void
To be added.
Copies the elements of the collection into a specified array, starting at the collection index.
An to copy into.
The collection index to begin copying from.
Property
1.0.5000.0
2.0.0.0
System.Int32
To be added.
To be added.
Gets the total number of objects managed by the .
Property
1.0.5000.0
2.0.0.0
System.Boolean
To be added.
This property is derived from , and is overridden to always return false.
Gets a value indicating whether the collection is synchronized.
Property
1.0.5000.0
2.0.0.0
System.Object
To be added.
To be added.
Gets an object to use for synchronization (thread safety).
Method
1.0.5000.0
2.0.0.0
System.Collections.IEnumerator
The returned by the method allows you to iterate over the collection managed by the .
Gets an enumerator for the collection.
An for the collection.
Method
2.0.0.0
System.Void
This method is intended update the bindings of components that implement , when their changes.
Associates a with a new .
The new to associate with the .
The to associate with the new .