Export (0) Print
Expand All

Binding.Control Property

Gets the control that the binding belongs to.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public Control Control { get; }
/** @property */
public Control get_Control ()

public function get Control () : Control

Property Value

The Control that the binding belongs to.

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

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());
   }
}

private void PrintBoundControls1()
{
    // Get the BindingManagerBase for the Customers table.
    BindingManagerBase myBindingBase = 
        this.get_BindingContext().get_Item(ds, "Customers");

    /* Print the information of each control managed by
       the BindingManagerBase. 
     */
    for (int iCtr = 0; iCtr < myBindingBase.get_Bindings().get_Count(); 
        iCtr++) {
        Binding b = myBindingBase.get_Bindings().get_Item(iCtr);
        Console.WriteLine(b.get_Control().ToString());
    }
} //PrintBoundControls1

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.get_BindingContext().get_Item(ds, "Customers.CustToOrders");
    /* Print the information of each control managed by
       the BindingManagerBase. 
     */
    for (int iCtr = 0; iCtr < myBindingBase.get_Bindings().get_Count();
        iCtr++) {
        Binding b = myBindingBase.get_Bindings().get_Item(iCtr);
        Console.WriteLine(b.get_Control().ToString());
    }
} //PrintBoundControls2

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());
   }
}

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft