Binding.PropertyName 属性

定义

获取控件的数据绑定属性的名称。

public:
 property System::String ^ PropertyName { System::String ^ get(); };
public string PropertyName { get; }
member this.PropertyName : string
Public ReadOnly Property PropertyName As String

属性值

要绑定到的控件属性的名称。

示例

下面的代码示例打印 PropertyName 窗体上每个 Binding 控件的每个 的值。

private:
   void PrintPropertyNameAndIsBinding()
   {
      for each ( Control^ thisControl in this->Controls)
      {
         for each ( Binding^ thisBinding in thisControl->DataBindings )
         {
            Console::WriteLine( "\n {0}", thisControl );
            // Print the PropertyName value for each binding.
            Console::WriteLine( thisBinding->PropertyName );
         }
      }
   }
private void PrintPropertyNameAndIsBinding()
{
   foreach(Control thisControl in this.Controls)
   {
      foreach(Binding thisBinding in thisControl.DataBindings)
      {
         Console.WriteLine("\n" + thisControl.ToString());
         // Print the PropertyName value for each binding.
         Console.WriteLine(thisBinding.PropertyName);
      }
   }
}
Private Sub PrintPropertyNameAndIsBinding
    Dim thisControl As Control
    Dim thisBinding As Binding
    For Each thisControl In Me.Controls
        For Each thisBinding In thisControl.DataBindings
            Console.WriteLine(ControlChars.CrLf & thisControl.ToString)
            ' Print the PropertyName value for each binding.
            Console.WriteLine(thisBinding.PropertyName)
        Next
    Next
End Sub

注解

PropertyName使用 指定要绑定到数据源中的列表的控件属性。 最常见的是绑定显示属性,例如 Text 控件的 TextBox 属性。 但是,由于可以绑定控件的任何属性,因此可以在运行时使用数据库中的数据以编程方式创建控件。

适用于