BindingsCollection Class

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Represents a collection of Binding objects 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

Public Class BindingsCollection
	Inherits BaseCollection

NameDescription
System_CAPS_pubpropertyCount

Gets the total number of bindings in the collection.(Overrides BaseCollection.Count.)

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.

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.(Overrides BaseCollection.List.)

System_CAPS_pubpropertySyncRoot

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

NameDescription
System_CAPS_protmethodAdd(Binding)

Adds the specified binding to the collection.

System_CAPS_protmethodAddCore(Binding)

This API supports the product infrastructure and is not intended to be used directly from your code. Adds a Binding to the collection.

System_CAPS_protmethodClear()

Clears the collection of binding objects.

System_CAPS_protmethodClearCore()

This API supports the product infrastructure and is not intended to be used directly from your code. Clears the collection of any members.

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.

System_CAPS_protmethodOnCollectionChanging(CollectionChangeEventArgs)

Raises the CollectionChanging event.

System_CAPS_protmethodRemove(Binding)

Deletes the specified binding from the collection.

System_CAPS_protmethodRemoveAt(Int32)

Deletes the binding from the collection 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.

System_CAPS_protmethodShouldSerializeMyAll()

Gets a value that indicates whether the collection should be serialized.

System_CAPS_pubmethodToString()

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

NameDescription
System_CAPS_pubeventCollectionChanged

Occurs when the collection has changed.

System_CAPS_pubeventCollectionChanging

Occurs when the collection is about to change.

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(Of TResult)()

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

System_CAPS_pubmethodOfType(Of 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 BindingsCollection. Any object that inherits from the Control class can access the BindingsCollection through the DataBindings property. For a list of Windows controls that support data binding, see the Binding class.

The following example binds the Text property of a TextBox control to a field in a database.

Private Sub BindTextBoxControl()
   Dim myDataSet As New DataSet()
   ' Insert code to populate the DataSet with tables, columns, and data.

   ' Creates a new Binding object. 
   Dim myBinding As New Binding("Text", myDataSet, _
   "customers.custToOrders.OrderAmount")

   ' Adds event delegates for the Parse and Format events.
   AddHandler myBinding.Parse, AddressOf CurrencyToDecimal
   AddHandler myBinding.Format, AddressOf DecimalToCurrency

   ' Adds the new Binding to the BindingsCollection.
   text1.DataBindings.Add(myBinding)
End Sub 

Private Sub DecimalToCurrency(sender As Object, _
   cevent As ConvertEventArgs)
   ' This method is the Format event handler. Whenever the
   ' control displays a new value, the value is converted from
   ' its native Decimal type to a string. The ToString method
   ' then formats the value as a Currency, by using the
   ' formatting character "c". 
   cevent.Value = CDec(cevent.Value).ToString("c")
End Sub 

Private Sub CurrencyToDecimal(sender As Object, _
cevent As ConvertEventArgs)
   ' This method is the Parse event handler. The Parse event
   ' occurs whenever the displayed value changes. The static
   ' Parse method of the Decimal structure converts the 
   ' string back to its native Decimal type. 
   cevent.Value = Decimal.Parse(cevent.Value.ToString(), _
   NumberStyles.Currency, nothing)
   End Sub 

.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: