Binding.PropertyName Binding.PropertyName Binding.PropertyName Binding.PropertyName Property

定义

获取控件的数据绑定属性的名称。Gets the name of the control's data-bound property.

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

属性值

要绑定到的控件属性的名称。The name of a control property to bind to.

示例

下面的代码示例将为PropertyName窗体上Binding的每个控件打印各自的值。The following code example prints the PropertyName value of each Binding for each control on a form.

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使用指定要绑定到数据源中的列表的控件属性。Use the PropertyName to specify the control property that you want to bind to a list in a data source. 最常见的情况是绑定显示属性 (如Text TextBox控件的属性)。Most commonly, you bind a display property such as the Text property of a TextBox control. 但是, 由于可以绑定控件的任何属性, 因此可以使用数据库中的数据以编程方式在运行时创建控件。However, because you can bind any property of a control, you can programmatically create controls at run time using data from a database.

适用于