Binding.PropertyName 属性

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

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public ReadOnly Property PropertyName As String
用法
Dim instance As Binding
Dim value As String

value = instance.PropertyName
public string PropertyName { get; }
public:
property String^ PropertyName {
    String^ get ();
}
/** @property */
public String get_PropertyName ()
public function get PropertyName () : String

属性值

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

备注

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

示例

下面的代码示例输出窗体上每个控件的每个 BindingPropertyName 值。

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:
   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()
{
    for (int iCtr1 = 0; iCtr1 < this.get_Controls().get_Count(); iCtr1++) {
        Control thisControl = this.get_Controls().get_Item(iCtr1);
        for (int iCtr2 = 0; 
            iCtr2 < thisControl.get_DataBindings().get_Count(); iCtr2++) {
            Binding thisBinding = 
                thisControl.get_DataBindings().get_Item(iCtr2);
            Console.WriteLine(("\n" + thisControl.ToString()));
            // Print the PropertyName value for each binding.
            Console.WriteLine(thisBinding.get_PropertyName());
        }
    }
} //PrintPropertyNameAndIsBinding
private function PrintPropertyNameAndIsBinding()
{
   for(var thisControl : Control in this.Controls)
   {
      for(var thisBinding : Binding in thisControl.DataBindings)
      {
         Console.WriteLine("\n" + thisControl.ToString());
         // Print the PropertyName value for each binding.
         Console.WriteLine(thisBinding.PropertyName);
      }
   }
}

平台

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

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

Binding 类
Binding 成员
System.Windows.Forms 命名空间