Binding.Control 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取绑定所属的控件。
public:
property System::Windows::Forms::Control ^ Control { System::Windows::Forms::Control ^ get(); };
public System.Windows.Forms.Control Control { get; }
public System.Windows.Forms.Control? Control { get; }
member this.Control : System.Windows.Forms.Control
Public ReadOnly Property Control As Control
属性值
绑定所属的 Control。
示例
下面的代码示例获取 BindingManagerBase 特定数据源的 ,并打印有关绑定到数据源的每个 Control 属性的信息。 该示例使用 Bindings 的 BindingManagerBase 属性来获取所有控件。
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. */
System::Collections::IEnumerator^ myEnum = myBindingBase->Bindings->GetEnumerator();
while ( myEnum->MoveNext() )
{
Binding^ b = safe_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[ ds,"Customers::CustToOrders" ];
/* Print the information of each control managed by
the BindingManagerBase. */
System::Collections::IEnumerator^ myEnum = myBindingBase->Bindings->GetEnumerator();
while ( myEnum->MoveNext() )
{
Binding^ b = safe_cast<Binding^>(myEnum->Current);
Console::WriteLine( b->Control );
}
}
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 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