JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Using the ControlBindingsCollection Class

The ControlBindingsCollection class holds a collection of Binding objects for a control. Here is the inheritance hierarchy for this class:

Object
   MarshalByRefObject
      BaseCollection
         BindingsCollection
            ControlBindingsCollection

You perform simple data binding by adding Binding objects to a ControlBindingsCollection. The ControlBindingsCollection contains standard collection methods such as Add, Clear, and Remove. As mentioned in the previous topic, we saw this example in the In Depth section of this chapter:

DateTimePicker1.DataBindings.Add _
    (New Binding("Value", DataSet11, "customers.DeliveryDate"))

And you also can use another overloaded form of the Add method to create a simple data binding, like this:

TextBox1.DataBindings.Add("Text", DataSet11, "authors.au_lname")

You can find the more notable public properties of ControlBindingsCollection objects in Table 21.1, their more notable methods in Table 21.2, and their more notable events in Table 21.3.

Table 21.1: Noteworthy public properties of ControlBindingsCollection objects.

Property

Means

Control

Gets the collection's associated control.

Count

Gets the number of items in the collection.

Item

Gets a binding.

Table 21.2: Noteworthy public methods of ControlBindingsCollection objects.

Method

Means

Add

Adds a binding.

Clear

Clears the collection.

Remove

Deletes a binding.

RemoveAt

Deletes a binding for the specified item.

Table 21.3: Noteworthy public events of ControlBindingsCollection objects.

Event

Means

CollectionChanged

Occurs when collection changes.

Previous Section Next Section




JavaScript Editor Free JavaScript Editor     JavaScript Editor