ControlBindingsCollection Class
TOC
Collapse the table of content
Expand the table of content

ControlBindingsCollection Class

 

Represents the collection of data bindings for a control.

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

System::Object
  System::MarshalByRefObject
    System.Windows.Forms::BaseCollection
      System.Windows.Forms::BindingsCollection
        System.Windows.Forms::ControlBindingsCollection

[TypeConverterAttribute("System.Windows.Forms.Design.ControlBindingsConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public ref class ControlBindingsCollection : BindingsCollection

NameDescription
System_CAPS_pubmethodControlBindingsCollection(IBindableComponent^)

Initializes a new instance of the ControlBindingsCollection class with the specified bindable control.

NameDescription
System_CAPS_pubpropertyBindableComponent

Gets the IBindableComponent the binding collection belongs to.

System_CAPS_pubpropertyControl

Gets the control that the collection belongs to.

System_CAPS_pubpropertyCount

Gets the total number of bindings in the collection.(Inherited from BindingsCollection.)

System_CAPS_pubpropertyDefaultDataSourceUpdateMode

Gets or sets the default DataSourceUpdateMode for a Binding in the collection.

System_CAPS_pubpropertyIsReadOnly

Gets a value indicating whether the collection is read-only.(Inherited from BaseCollection.)

System_CAPS_pubpropertyIsSynchronized

Gets a value indicating whether access to the ICollection is synchronized.(Inherited from BaseCollection.)

System_CAPS_pubpropertyItem[Int32]

Gets the Binding at the specified index.(Inherited from BindingsCollection.)

System_CAPS_pubpropertyItem[String^]

Gets the Binding specified by the control's property name.

System_CAPS_protpropertyList

This API supports the product infrastructure and is not intended to be used directly from your code. Gets the bindings in the collection as an object.(Inherited from BindingsCollection.)

System_CAPS_pubpropertySyncRoot

Gets an object that can be used to synchronize access to the BaseCollection.(Inherited from BaseCollection.)

NameDescription
System_CAPS_pubmethodAdd(Binding^)

Adds the specified Binding to the collection.

System_CAPS_pubmethodAdd(String^, Object^, String^)

Creates a Binding using the specified control property name, data source, and data member, and adds it to the collection.

System_CAPS_pubmethodAdd(String^, Object^, String^, Boolean)

Creates a binding with the specified control property name, data source, data member, and information about whether formatting is enabled, and adds the binding to the collection.

System_CAPS_pubmethodAdd(String^, Object^, String^, Boolean, DataSourceUpdateMode)

Creates a binding that binds the specified control property to the specified data member of the specified data source, optionally enabling formatting, propagating values to the data source based on the specified update setting, and adding the binding to the collection.

System_CAPS_pubmethodAdd(String^, Object^, String^, Boolean, DataSourceUpdateMode, Object^)

Creates a binding that binds the specified control property to the specified data member of the specified data source, optionally enabling formatting, propagating values to the data source based on the specified update setting, setting the property to the specified value when DBNull is returned from the data source, and adding the binding to the collection.

System_CAPS_pubmethodAdd(String^, Object^, String^, Boolean, DataSourceUpdateMode, Object^, String^)

Creates a binding that binds the specified control property to the specified data member of the specified data source, optionally enabling formatting with the specified format string, propagating values to the data source based on the specified update setting, setting the property to the specified value when DBNull is returned from the data source, and adding the binding to the collection.

System_CAPS_pubmethodAdd(String^, Object^, String^, Boolean, DataSourceUpdateMode, Object^, String^, IFormatProvider^)

Creates a binding that binds the specified control property to the specified data member of the specified data source, optionally enabling formatting with the specified format string, propagating values to the data source based on the specified update setting, setting the property to the specified value when DBNull is returned from the data source, setting the specified format provider, and adding the binding to the collection.

System_CAPS_protmethodAddCore(Binding^)

Adds a binding to the collection.(Overrides BindingsCollection::AddCore(Binding^).)

System_CAPS_pubmethodClear()

Clears the collection of any bindings.

System_CAPS_protmethodClearCore()

This API supports the product infrastructure and is not intended to be used directly from your code. Clears the bindings in the collection.(Overrides BindingsCollection::ClearCore().)

System_CAPS_pubmethodCopyTo(Array^, Int32)

Copies all the elements of the current one-dimensional Array to the specified one-dimensional Array starting at the specified destination Array index.(Inherited from BaseCollection.)

System_CAPS_pubmethodCreateObjRef(Type^)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodEquals(Object^)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetEnumerator()

Gets the object that enables iterating through the members of the collection.(Inherited from BaseCollection.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodInitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.(Inherited from MarshalByRefObject.)

System_CAPS_protmethodOnCollectionChanged(CollectionChangeEventArgs^)

Raises the CollectionChanged event.(Inherited from BindingsCollection.)

System_CAPS_protmethodOnCollectionChanging(CollectionChangeEventArgs^)

Raises the CollectionChanging event. (Inherited from BindingsCollection.)

System_CAPS_pubmethodRemove(Binding^)

Deletes the specified Binding from the collection.

System_CAPS_pubmethodRemoveAt(Int32)

Deletes the Binding at the specified index.

System_CAPS_protmethodRemoveCore(Binding^)

This API supports the product infrastructure and is not intended to be used directly from your code. Removes the specified binding from the collection.(Overrides BindingsCollection::RemoveCore(Binding^).)

System_CAPS_protmethodShouldSerializeMyAll()

Gets a value that indicates whether the collection should be serialized.(Inherited from BindingsCollection.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubeventCollectionChanged

Occurs when the collection has changed.(Inherited from BindingsCollection.)

System_CAPS_pubeventCollectionChanging

Occurs when the collection is about to change.(Inherited from BindingsCollection.)

NameDescription
System_CAPS_pubmethodAsParallel()

Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.)

System_CAPS_pubmethodAsQueryable()

Overloaded. Converts an IEnumerable to an IQueryable.(Defined by Queryable.)

System_CAPS_pubmethodCast<TResult>()

Casts the elements of an IEnumerable to the specified type.(Defined by Enumerable.)

System_CAPS_pubmethodOfType<TResult>()

Filters the elements of an IEnumerable based on a specified type.(Defined by Enumerable.)

Simple data binding is accomplished by adding Binding objects to a ControlBindingsCollection. Any object that inherits from the Control class can access the ControlBindingsCollection through the DataBindings property. For a list of Windows controls that support data binding, see the Binding class.

The ControlBindingsCollection contains standard collection methods such as Add, Clear, and Remove.

To get the control that the ControlBindingsCollection belongs to, use the Control property.

The following code example adds Binding objects to a ControlBindingsCollection of five controls: four TextBox controls and a DateTimePicker control. The ControlBindingsCollection is accessed through the DataBindings property of the Control class.

protected:
   void BindControls()
   {
      /* Create two Binding objects for the first two TextBox 
         controls. The data-bound property for both controls 
         is the Text property. The data source is a DataSet 
         (ds). The data member is the navigation path: 
         TableName.ColumnName. */
      textBox1->DataBindings->Add( gcnew Binding(
         "Text",ds,"customers.custName" ) );
      textBox2->DataBindings->Add( gcnew Binding(
         "Text",ds,"customers.custID" ) );

      /* Bind the DateTimePicker control by adding a new Binding. 
         The data member of the DateTimePicker is a navigation path:
         TableName.RelationName.ColumnName. */
      DateTimePicker1->DataBindings->Add( gcnew Binding(
         "Value",ds,"customers.CustToOrders.OrderDate" ) );

      /* Create a new Binding using the DataSet and a 
         navigation path(TableName.RelationName.ColumnName).
         Add event delegates for the Parse and Format events to 
         the Binding object, and add the object to the third 
         TextBox control's BindingsCollection. The delegates 
         must be added before adding the Binding to the 
         collection; otherwise, no formatting occurs until 
         the Current object of the BindingManagerBase for 
         the data source changes. */
      Binding^ b = gcnew Binding(
         "Text",ds,"customers.custToOrders.OrderAmount" );
      b->Parse += gcnew ConvertEventHandler(
         this, &Form1::CurrencyStringToDecimal );
      b->Format += gcnew ConvertEventHandler(
         this, &Form1::DecimalToCurrencyString );
      textBox3->DataBindings->Add( b );

      /*Bind the fourth TextBox to the Value of the 
         DateTimePicker control. This demonstates how one control
         can be data-bound to another.*/
      textBox4->DataBindings->Add( "Text", DateTimePicker1, "Value" );

      // Get the BindingManagerBase for the textBox4 Binding.
      BindingManagerBase^ bmText = this->BindingContext[
         DateTimePicker1 ];

      /* Print the Type of the BindingManagerBase, which is 
         a PropertyManager because the data source
         returns only a single property value. */
      Console::WriteLine( bmText->GetType() );

      // Print the count of managed objects, which is one.
      Console::WriteLine( bmText->Count );

      // Get the BindingManagerBase for the Customers table. 
      bmCustomers = this->BindingContext[ds, "Customers"];

      /* Print the Type and count of the BindingManagerBase.
         Because the data source inherits from IBindingList,
         it is a RelatedCurrencyManager (a derived class of
         CurrencyManager). */
      Console::WriteLine( bmCustomers->GetType() );
      Console::WriteLine( bmCustomers->Count );

      /* Get the BindingManagerBase for the Orders of the current
         customer using a navigation path: TableName.RelationName. */
      bmOrders = this->BindingContext[ds, "customers.CustToOrders"];
   }

.NET Framework
Available since 1.1

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

Return to top
Show:
© 2016 Microsoft