This documentation is archived and is not being maintained.

Binding.Control Property

Gets the control that the binding belongs to.

[Visual Basic]
Public ReadOnly Property Control As Control
[C#]
public Control Control {get;}
[C++]
public: __property Control* get_Control();
[JScript]
public function get Control() : Control;

Property Value

The Control that the binding belongs to.

Example

The following example gets the BindingManagerBase for a specific data source, and prints information about each Control that is bound to the data source. The example uses the Bindings property of the BindingManagerBase to get all controls.

[Visual Basic] 
Private Sub PrintBoundControls1
   ' Gets the BindingManagerBase for the Customers table.
   Dim myBindingBase As BindingManagerBase = _
   Me.BindingContext(ds, "Customers")

   ' Prints the information of each control managed by
   ' the BindingManagerBase.
   Dim b As Binding
   For Each b In myBindingBase.Bindings
      Console.WriteLine(b.Control.ToString)
   Next
End Sub

Private Sub PrintBoundControls2
   ' Gets the BindingManagerBase for a child table of
   ' the Customers table. The RelationName of a DataRelation
   ' is appended to the parent table's name.
   Dim myBindingBase As BindingManagerBase = _
   Me.BindingContext(ds, "Customers.CustToOrders")


   ' Prints the information of each control managed by
   ' the BindingManagerBase.
   Dim b As Binding
   For Each b In myBindingBase.Bindings
      Console.WriteLine(b.Control.ToString)
   Next
End Sub

[C#] 
private void PrintBoundControls1()
{
   // Get the BindingManagerBase for the Customers table.
   BindingManagerBase myBindingBase = 
      this.BindingContext[ds, "Customers"];

   /* Print the information of each control managed by
      the BindingManagerBase. */
   foreach(Binding b in myBindingBase.Bindings)
   {
      Console.WriteLine(b.Control.ToString());
   }
}

private void PrintBoundControls2()
{
   /* Get the BindingManagerBase for a child table of
   the Customers table. The RelationName of a DataRelation
   is appended to the parent table's name. */
   BindingManagerBase myBindingBase = 
      this.BindingContext[ds, "Customers.CustToOrders"];

   /* Print the information of each control managed by
      the BindingManagerBase. */
   foreach(Binding b in myBindingBase.Bindings)
   {
      Console.WriteLine(b.Control.ToString());
   }
}

[C++] 
private:
   void PrintBoundControls1() {
      // Get the BindingManagerBase for the Customers table.
      BindingManagerBase* myBindingBase =
         this->BindingContext->Item[ds, S"Customers"];

      /* Print the information of each control managed by
      the BindingManagerBase. */
      System::Collections::IEnumerator* myEnum = myBindingBase->Bindings->GetEnumerator();
      while (myEnum->MoveNext()) {
         Binding* b = __try_cast<Binding*>(myEnum->Current);
         Console::WriteLine(b->Control);
      }
   }

   void PrintBoundControls2() {
      /* Get the BindingManagerBase for a child table of
      the Customers table. The RelationName of a DataRelation
      is appended to the parent table's name. */
      BindingManagerBase* myBindingBase =
         this->BindingContext->Item[ds, S"Customers::CustToOrders"];

      /* Print the information of each control managed by
      the BindingManagerBase. */
      System::Collections::IEnumerator* myEnum = myBindingBase->Bindings->GetEnumerator();
      while (myEnum->MoveNext()) {
         Binding* b = __try_cast<Binding*>(myEnum->Current);
         Console::WriteLine(b->Control);
      }
   }

[JScript] 
private function PrintBoundControls1()
{
   // Get the BindingManagerBase for the Customers table.
   var myBindingBase : BindingManagerBase = 
      this.BindingContext[ds, "Customers"];

   /* Print the information of each control managed by
      the BindingManagerBase. */
   for(var b : Binding in myBindingBase.Bindings)
   {
      Console.WriteLine(b.Control.ToString());
   }
}

private function PrintBoundControls2()
{
   /* Get the BindingManagerBase for a child table of
   the Customers table. The RelationName of a DataRelation
   is appended to the parent table's name. */
   var myBindingBase : BindingManagerBase  = 
      this.BindingContext[ds, "Customers.CustToOrders"];

   /* Print the information of each control managed by
      the BindingManagerBase. */
   for(var b : Binding in myBindingBase.Bindings)
   {
      Console.WriteLine(b.Control.ToString());
   }
}

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

Binding Class | Binding Members | System.Windows.Forms Namespace

Show: