ControlBindingsCollection.Add ControlBindingsCollection.Add ControlBindingsCollection.Add ControlBindingsCollection.Add Method

定义

Binding 添加到集合。Adds a Binding to the collection.

重载

Add(Binding) Add(Binding) Add(Binding)

将指定的 Binding 添加到集合。Adds the specified Binding to the collection.

Add(String, Object, String) Add(String, Object, String) Add(String, Object, String) Add(String, Object, String)

使用指定的控件属性名、数据源和数据成员创建 Binding,并将其添加到集合中。Creates a Binding using the specified control property name, data source, and data member, and adds it to the collection.

Add(String, Object, String, Boolean) Add(String, Object, String, Boolean) Add(String, Object, String, Boolean) Add(String, Object, String, Boolean)

用指定的控件属性名称、数据源、数据成员以及有关格式设置是否启用的信息创建绑定,并将该绑定添加到集合中。Creates a binding with the specified control property name, data source, data member, and information about whether formatting is enabled, and adds the binding to the collection.

Add(String, Object, String, Boolean, DataSourceUpdateMode) Add(String, Object, String, Boolean, DataSourceUpdateMode) Add(String, Object, String, Boolean, DataSourceUpdateMode) Add(String, Object, String, Boolean, DataSourceUpdateMode)

创建将指定控件属性绑定到指定数据源的指定数据成员的绑定,同时可选地启用格式设置,根据指定的更新设置将值传播到数据源,并将该绑定添加到集合。Creates a binding that binds the specified control property to the specified data member of the specified data source, optionally enabling formatting, propagating values to the data source based on the specified update setting, and adding the binding to the collection.

Add(String, Object, String, Boolean, DataSourceUpdateMode, Object) Add(String, Object, String, Boolean, DataSourceUpdateMode, Object) Add(String, Object, String, Boolean, DataSourceUpdateMode, Object) Add(String, Object, String, Boolean, DataSourceUpdateMode, Object)

创建将指定控件属性绑定到指定数据源的指定数据成员的绑定,同时可选地启用格式设置,根据指定的更新设置将值传播到数据源,当从数据源返回 DBNull 时将该属性设置为指定的值,并将该绑定添加到集合。Creates a binding that binds the specified control property to the specified data member of the specified data source, optionally enabling formatting, propagating values to the data source based on the specified update setting, setting the property to the specified value when DBNull is returned from the data source, and adding the binding to the collection.

Add(String, Object, String, Boolean, DataSourceUpdateMode, Object, String) Add(String, Object, String, Boolean, DataSourceUpdateMode, Object, String) Add(String, Object, String, Boolean, DataSourceUpdateMode, Object, String) Add(String, Object, String, Boolean, DataSourceUpdateMode, Object, String)

创建将指定控件属性绑定到指定数据源的指定数据成员的绑定,同时可选地以指定的格式字符串启用格式设置、根据指定的更新设置将值传播到数据源、当从数据源返回 DBNull 时将该属性设置为指定的值,并将该绑定添加到集合。Creates a binding that binds the specified control property to the specified data member of the specified data source, optionally enabling formatting with the specified format string, propagating values to the data source based on the specified update setting, setting the property to the specified value when DBNull is returned from the data source, and adding the binding to the collection.

Add(String, Object, String, Boolean, DataSourceUpdateMode, Object, String, IFormatProvider) Add(String, Object, String, Boolean, DataSourceUpdateMode, Object, String, IFormatProvider) Add(String, Object, String, Boolean, DataSourceUpdateMode, Object, String, IFormatProvider) Add(String, Object, String, Boolean, DataSourceUpdateMode, Object, String, IFormatProvider)

创建将指定控件属性绑定到指定数据源的指定数据成员的绑定,同时可选地以指定的格式字符串启用格式设置、根据指定的更新设置将值传播到数据源、当从数据源返回 DBNull 时将该属性设置为指定的值、设置指定的格式提供程序,并将该绑定添加到集合。Creates a binding that binds the specified control property to the specified data member of the specified data source, optionally enabling formatting with the specified format string, propagating values to the data source based on the specified update setting, setting the property to the specified value when DBNull is returned from the data source, setting the specified format provider, and adding the binding to the collection.

Add(Binding) Add(Binding) Add(Binding)

将指定的 Binding 添加到集合。Adds the specified Binding to the collection.

public:
 void Add(System::Windows::Forms::Binding ^ binding);
public void Add (System.Windows.Forms.Binding binding);
override this.Add : System.Windows.Forms.Binding -> unit

参数

binding
Binding Binding Binding Binding

要添加的 BindingThe Binding to add.

异常

控件属性已绑定到数据。The control property is already data-bound.

- 或 --or-

Binding 未指定 DataSource 的有效列。The Binding does not specify a valid column of the DataSource.

示例

下面的代码示例创建一个Binding实例, 并Add使用方法ControlBindingsCollection将该TextBox实例添加到控件的。The following code example creates a Binding instance, and uses the Add method to add the instance to the ControlBindingsCollection of a TextBox control.

protected:
   void BindControls()
   {
      /* Create a new Binding using the DataSet and a 
         navigation path(TableName.RelationName.ColumnName).
         Add event delegates for the Parse and Format events to 
         the Binding object, and add the object to the third 
         TextBox control's BindingsCollection. The delegates 
         must be added before adding the Binding to the 
         collection; otherwise, no formatting occurs until 
         the Current object of the BindingManagerBase for 
         the data source changes. */
      Binding^ b = gcnew Binding(
         "Text",ds,"customers.custToOrders.OrderAmount" );
      b->Parse += gcnew ConvertEventHandler(
         this, &Form1::CurrencyStringToDecimal );
      b->Format += gcnew ConvertEventHandler(
         this, &Form1::DecimalToCurrencyString );
      textBox1->DataBindings->Add( b );
   }
protected void BindControls()
{
   /* Create a new Binding using the DataSet and a 
   navigation path(TableName.RelationName.ColumnName).
   Add event delegates for the Parse and Format events to 
   the Binding object, and add the object to the third 
   TextBox control's BindingsCollection. The delegates 
   must be added before adding the Binding to the 
   collection; otherwise, no formatting occurs until 
   the Current object of the BindingManagerBase for 
   the data source changes. */
   Binding b = new Binding
   ("Text", ds, "customers.custToOrders.OrderAmount");
   b.Parse+=new ConvertEventHandler(CurrencyStringToDecimal);
   b.Format+=new ConvertEventHandler(DecimalToCurrencyString);
   textBox1.DataBindings.Add(b);
}
Protected Sub BindControls()
    ' Create a new Binding using the DataSet and a 
    ' navigation path(TableName.RelationName.ColumnName).
    ' Add event delegates for the Parse and Format events to 
    ' the Binding object, and add the object to the third 
    ' TextBox control's BindingsCollection. The delegates 
    ' must be added before adding the Binding to the 
    ' collection; otherwise, no formatting occurs until 
    ' the Current object of the BindingManagerBase for 
    ' the data source changes. 
    Dim b As New Binding("Text", ds, "customers.custToOrders.OrderAmount")
    AddHandler b.Parse, AddressOf CurrencyStringToDecimal
    AddHandler b.Format, AddressOf DecimalToCurrencyString
    textBox1.DataBindings.Add(b)
End Sub    

注解

DataSourceUpdateMode 方法的Add重载Binding创建的的属性设置为属性的值。DefaultDataSourceUpdateModeThe DataSourceUpdateMode property of the Binding created by this overload of the Add method is set to the value of the DefaultDataSourceUpdateMode property.

更改CollectionChanged完成后发生该事件。The CollectionChanged event occurs when the change is complete.

Add(String, Object, String) Add(String, Object, String) Add(String, Object, String) Add(String, Object, String)

使用指定的控件属性名、数据源和数据成员创建 Binding,并将其添加到集合中。Creates a Binding using the specified control property name, data source, and data member, and adds it to the collection.

public:
 System::Windows::Forms::Binding ^ Add(System::String ^ propertyName, System::Object ^ dataSource, System::String ^ dataMember);
public System.Windows.Forms.Binding Add (string propertyName, object dataSource, string dataMember);
override this.Add : string * obj * string -> System.Windows.Forms.Binding
Public Function Add (propertyName As String, dataSource As Object, dataMember As String) As Binding

参数

propertyName
String String String String

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

dataSource
Object Object Object Object

表示数据源的 ObjectAn Object that represents the data source.

dataMember
String String String String

要绑定到的属性或列表。The property or list to bind to.

返回

新创建的 BindingThe newly created Binding.

异常

propertyName 已绑定到数据。The propertyName is already data-bound.

-or-

dataMember 未指定 dataSource 的有效成员。The dataMember doesn't specify a valid member of the dataSource.

示例

下面的代码示例Add使用方法将三个Binding TextBox对象添加到ControlBindingsCollection控件的。The following code example uses the Add method to add three Binding objects to the ControlBindingsCollection of a TextBox control. 通过 ControlBindingsCollection 类的 DataBindings 属性来访问 ControlThe ControlBindingsCollection is accessed through the DataBindings property of the Control class.

private:
   void BindTextBoxProperties()
   {
      // Clear the collection before adding new Binding objects.
      textBox1->DataBindings->Clear();

      // Create a DataTable containing Color objects.
      DataTable^ t = MakeTable();

      /* Bind the Text, BackColor, and ForeColor properties
         to columns in the DataTable. */
      textBox1->DataBindings->Add( "Text", t, "Text" );
      textBox1->DataBindings->Add( "BackColor", t, "BackColor" );
      textBox1->DataBindings->Add( "ForeColor", t, "ForeColor" );
   }

   DataTable^ MakeTable()
   {
      /* Create a DataTable with three columns.
         Two of the columns contain Color objects. */
      DataTable^ t = gcnew DataTable( "Control" );
      t->Columns->Add( "BackColor", Color::typeid );
      t->Columns->Add( "ForeColor", Color::typeid );
      t->Columns->Add( "Text" );

      // Add three rows to the table.
      DataRow^ r;
      r = t->NewRow();
      r[ "BackColor" ] = Color::Blue;
      r[ "ForeColor" ] = Color::Yellow;
      r[ "Text" ] = "Yellow on Blue";
      t->Rows->Add( r );
      r = t->NewRow();
      r[ "BackColor" ] = Color::White;
      r[ "ForeColor" ] = Color::Green;
      r[ "Text" ] = "Green on white";
      t->Rows->Add( r );
      r = t->NewRow();
      r[ "BackColor" ] = Color::Orange;
      r[ "ForeColor" ] = Color::Black;
      r[ "Text" ] = "Black on Orange";
      t->Rows->Add( r );
      return t;
   }
private void BindTextBoxProperties()
{
   // Clear the collection before adding new Binding objects.
   textBox1.DataBindings.Clear();

   // Create a DataTable containing Color objects.
   DataTable t = MakeTable();

   /* Bind the Text, BackColor, and ForeColor properties
   to columns in the DataTable. */
   textBox1.DataBindings.Add("Text", t, "Text");
   textBox1.DataBindings.Add("BackColor", t, "BackColor");
   textBox1.DataBindings.Add("ForeColor", t, "ForeColor");
}

private DataTable MakeTable()
{
   /* Create a DataTable with three columns.
   Two of the columns contain Color objects. */

   DataTable t = new DataTable("Control");
   t.Columns.Add("BackColor", typeof(Color));
   t.Columns.Add("ForeColor", typeof(Color));
   t.Columns.Add("Text");

   // Add three rows to the table.
   DataRow r;

   r = t.NewRow();
   r["BackColor"] = Color.Blue;
   r["ForeColor"] = Color.Yellow;
   r["Text"] = "Yellow on Blue";
   t.Rows.Add(r);

   r = t.NewRow();
   r["BackColor"] = Color.White;
   r["ForeColor"] = Color.Green;
   r["Text"] = "Green on white";
   t.Rows.Add(r);

   r = t.NewRow();
   r["BackColor"] = Color.Orange;
   r["ForeColor"] = Color.Black;
   r["Text"] = "Black on Orange";
   t.Rows.Add(r);

   return t;
}
Private Sub BindTextBoxProperties()
    ' Clear the collection before adding new Binding objects.
    textBox1.DataBindings.Clear()
    
    ' Create a DataTable containing Color objects.
    Dim t As DataTable = MakeTable()
    
    ' Bind the Text, BackColor, and ForeColor properties
    ' to columns in the DataTable. 
    textBox1.DataBindings.Add("Text", t, "Text")
    textBox1.DataBindings.Add("BackColor", t, "BackColor")
    textBox1.DataBindings.Add("ForeColor", t, "ForeColor")
End Sub    

Private Function MakeTable() As DataTable
    ' Create a DataTable with three columns.
    ' Two of the columns contain Color objects. 
    
    Dim t As New DataTable("Control")
    t.Columns.Add("BackColor", GetType(Color))
    t.Columns.Add("ForeColor", GetType(Color))
    t.Columns.Add("Text")
    
    ' Add three rows to the table.
    Dim r As DataRow
    
    r = t.NewRow()
    r("BackColor") = Color.Blue
    r("ForeColor") = Color.Yellow
    r("Text") = "Yellow on Blue"
    t.Rows.Add(r)
    
    r = t.NewRow()
    r("BackColor") = Color.White
    r("ForeColor") = Color.Green
    r("Text") = "Green on white"
    t.Rows.Add(r)
    
    r = t.NewRow()
    r("BackColor") = Color.Orange
    r("ForeColor") = Color.Black
    r("Text") = "Black on Orange"
    t.Rows.Add(r)
    
    Return t
End Function

注解

DataSourceUpdateMode 方法的Add重载Binding创建的的属性设置为属性的值。DefaultDataSourceUpdateModeThe DataSourceUpdateMode property of the Binding created by this overload of the Add method is set to the value of the DefaultDataSourceUpdateMode property.

Binding 添加CollectionChanged会导致事件发生。Adding a Binding causes the CollectionChanged event to occur.

Add(String, Object, String, Boolean) Add(String, Object, String, Boolean) Add(String, Object, String, Boolean) Add(String, Object, String, Boolean)

用指定的控件属性名称、数据源、数据成员以及有关格式设置是否启用的信息创建绑定,并将该绑定添加到集合中。Creates a binding with the specified control property name, data source, data member, and information about whether formatting is enabled, and adds the binding to the collection.

public:
 System::Windows::Forms::Binding ^ Add(System::String ^ propertyName, System::Object ^ dataSource, System::String ^ dataMember, bool formattingEnabled);
public System.Windows.Forms.Binding Add (string propertyName, object dataSource, string dataMember, bool formattingEnabled);
override this.Add : string * obj * string * bool -> System.Windows.Forms.Binding
Public Function Add (propertyName As String, dataSource As Object, dataMember As String, formattingEnabled As Boolean) As Binding

参数

propertyName
String String String String

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

dataSource
Object Object Object Object

表示数据源的 ObjectAn Object representing the data source.

dataMember
String String String String

要绑定到的属性或列表。The property or list to bind to.

formattingEnabled
Boolean Boolean Boolean Boolean

若要格式化显示的数据,则为 true;否则为 falsetrue to format the displayed data; otherwise, false

返回

新创建的 BindingThe newly created Binding.

异常

在该控件中不存在由 propertyName 给出的属性。The property given by propertyName does not exist on the control.

-or- 给定的属性为只读属性。The property given is a read-only property.

如果禁用格式设置,且 propertyName 既不是有效的控件属性,也不是空字符串 ("")。If formatting is disabled and the propertyName is neither a valid property of a control nor an empty string ("").

Add(String, Object, String, Boolean, DataSourceUpdateMode) Add(String, Object, String, Boolean, DataSourceUpdateMode) Add(String, Object, String, Boolean, DataSourceUpdateMode) Add(String, Object, String, Boolean, DataSourceUpdateMode)

创建将指定控件属性绑定到指定数据源的指定数据成员的绑定,同时可选地启用格式设置,根据指定的更新设置将值传播到数据源,并将该绑定添加到集合。Creates a binding that binds the specified control property to the specified data member of the specified data source, optionally enabling formatting, propagating values to the data source based on the specified update setting, and adding the binding to the collection.

public:
 System::Windows::Forms::Binding ^ Add(System::String ^ propertyName, System::Object ^ dataSource, System::String ^ dataMember, bool formattingEnabled, System::Windows::Forms::DataSourceUpdateMode updateMode);
public System.Windows.Forms.Binding Add (string propertyName, object dataSource, string dataMember, bool formattingEnabled, System.Windows.Forms.DataSourceUpdateMode updateMode);
override this.Add : string * obj * string * bool * System.Windows.Forms.DataSourceUpdateMode -> System.Windows.Forms.Binding
Public Function Add (propertyName As String, dataSource As Object, dataMember As String, formattingEnabled As Boolean, updateMode As DataSourceUpdateMode) As Binding

参数

propertyName
String String String String

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

dataSource
Object Object Object Object

表示数据源的 ObjectAn Object representing the data source.

dataMember
String String String String

要绑定到的属性或列表。The property or list to bind to.

formattingEnabled
Boolean Boolean Boolean Boolean

若要格式化显示的数据,则为 true;否则为 falsetrue to format the displayed data; otherwise, false.

返回

新创建的 BindingThe newly created Binding.

异常

propertyName 给出的属性在该控件上不存在或者为只读。The property given by propertyName does not exist on the control or is read-only.

-or- 数据源中不存在指定的数据成员。The specified data member does not exist on the data source.

-or- 指定的数据源、数据成员或控件属性与集合中的另一个绑定相关联。The data source, data member, or control property specified are associated with another binding in the collection.

注解

调用方法会引发CollectionChanged事件。 AddCalling the Add method raises the CollectionChanged event.

Add(String, Object, String, Boolean, DataSourceUpdateMode, Object) Add(String, Object, String, Boolean, DataSourceUpdateMode, Object) Add(String, Object, String, Boolean, DataSourceUpdateMode, Object) Add(String, Object, String, Boolean, DataSourceUpdateMode, Object)

创建将指定控件属性绑定到指定数据源的指定数据成员的绑定,同时可选地启用格式设置,根据指定的更新设置将值传播到数据源,当从数据源返回 DBNull 时将该属性设置为指定的值,并将该绑定添加到集合。Creates a binding that binds the specified control property to the specified data member of the specified data source, optionally enabling formatting, propagating values to the data source based on the specified update setting, setting the property to the specified value when DBNull is returned from the data source, and adding the binding to the collection.

public:
 System::Windows::Forms::Binding ^ Add(System::String ^ propertyName, System::Object ^ dataSource, System::String ^ dataMember, bool formattingEnabled, System::Windows::Forms::DataSourceUpdateMode updateMode, System::Object ^ nullValue);
public System.Windows.Forms.Binding Add (string propertyName, object dataSource, string dataMember, bool formattingEnabled, System.Windows.Forms.DataSourceUpdateMode updateMode, object nullValue);
override this.Add : string * obj * string * bool * System.Windows.Forms.DataSourceUpdateMode * obj -> System.Windows.Forms.Binding
Public Function Add (propertyName As String, dataSource As Object, dataMember As String, formattingEnabled As Boolean, updateMode As DataSourceUpdateMode, nullValue As Object) As Binding

参数

propertyName
String String String String

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

dataSource
Object Object Object Object

表示数据源的 ObjectAn Object representing the data source.

dataMember
String String String String

要绑定到的属性或列表。The property or list to bind to.

formattingEnabled
Boolean Boolean Boolean Boolean

若要格式化显示的数据,则为 true;否则为 falsetrue to format the displayed data; otherwise, false.

nullValue
Object Object Object Object

如果数据具有此值,则绑定属性设置为 DBNullWhen the data source has this value, the bound property is set to DBNull.

返回

新创建的 BindingThe newly created Binding

异常

propertyName 给出的属性在该控件上不存在或者为只读。The property given by propertyName does not exist on the control or is read-only.

- 或 --or- 数据源中不存在指定的数据成员。The specified data member does not exist on the data source.

-or- 指定的数据源、数据成员或控件属性与集合中的另一个绑定相关联。The data source, data member, or control property specified are associated with another binding in the collection.

注解

调用方法会引发CollectionChanged事件。 AddCalling the Add method raises the CollectionChanged event.

Add(String, Object, String, Boolean, DataSourceUpdateMode, Object, String) Add(String, Object, String, Boolean, DataSourceUpdateMode, Object, String) Add(String, Object, String, Boolean, DataSourceUpdateMode, Object, String) Add(String, Object, String, Boolean, DataSourceUpdateMode, Object, String)

创建将指定控件属性绑定到指定数据源的指定数据成员的绑定,同时可选地以指定的格式字符串启用格式设置、根据指定的更新设置将值传播到数据源、当从数据源返回 DBNull 时将该属性设置为指定的值,并将该绑定添加到集合。Creates a binding that binds the specified control property to the specified data member of the specified data source, optionally enabling formatting with the specified format string, propagating values to the data source based on the specified update setting, setting the property to the specified value when DBNull is returned from the data source, and adding the binding to the collection.

public:
 System::Windows::Forms::Binding ^ Add(System::String ^ propertyName, System::Object ^ dataSource, System::String ^ dataMember, bool formattingEnabled, System::Windows::Forms::DataSourceUpdateMode updateMode, System::Object ^ nullValue, System::String ^ formatString);
public System.Windows.Forms.Binding Add (string propertyName, object dataSource, string dataMember, bool formattingEnabled, System.Windows.Forms.DataSourceUpdateMode updateMode, object nullValue, string formatString);
override this.Add : string * obj * string * bool * System.Windows.Forms.DataSourceUpdateMode * obj * string -> System.Windows.Forms.Binding
Public Function Add (propertyName As String, dataSource As Object, dataMember As String, formattingEnabled As Boolean, updateMode As DataSourceUpdateMode, nullValue As Object, formatString As String) As Binding

参数

propertyName
String String String String

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

dataSource
Object Object Object Object

表示数据源的 ObjectAn Object representing the data source.

dataMember
String String String String

要绑定到的属性或列表。The property or list to bind to.

formattingEnabled
Boolean Boolean Boolean Boolean

若要格式化显示的数据,则为 true;否则为 falsetrue to format the displayed data; otherwise, false.

nullValue
Object Object Object Object

如果数据具有此值,则绑定属性设置为 DBNullWhen the data source has this value, the bound property is set to DBNull.

formatString
String String String String

一个或多个格式说明符,指示如何显示值。One or more format specifier characters that indicate how a value is to be displayed.

返回

新创建的 BindingThe newly created Binding

异常

propertyName 给出的属性在该控件上不存在或者为只读。The property given by propertyName does not exist on the control or is read-only.

-or- 数据源中不存在指定的数据成员。The specified data member does not exist on the data source.

- 或 --or- 指定的数据源、数据成员或控件属性与集合中的另一个绑定相关联。The data source, data member, or control property specified are associated with another binding in the collection.

注解

调用方法会引发CollectionChanged事件。 AddCalling the Add method raises the CollectionChanged event.

Add(String, Object, String, Boolean, DataSourceUpdateMode, Object, String, IFormatProvider) Add(String, Object, String, Boolean, DataSourceUpdateMode, Object, String, IFormatProvider) Add(String, Object, String, Boolean, DataSourceUpdateMode, Object, String, IFormatProvider) Add(String, Object, String, Boolean, DataSourceUpdateMode, Object, String, IFormatProvider)

创建将指定控件属性绑定到指定数据源的指定数据成员的绑定,同时可选地以指定的格式字符串启用格式设置、根据指定的更新设置将值传播到数据源、当从数据源返回 DBNull 时将该属性设置为指定的值、设置指定的格式提供程序,并将该绑定添加到集合。Creates a binding that binds the specified control property to the specified data member of the specified data source, optionally enabling formatting with the specified format string, propagating values to the data source based on the specified update setting, setting the property to the specified value when DBNull is returned from the data source, setting the specified format provider, and adding the binding to the collection.

public:
 System::Windows::Forms::Binding ^ Add(System::String ^ propertyName, System::Object ^ dataSource, System::String ^ dataMember, bool formattingEnabled, System::Windows::Forms::DataSourceUpdateMode updateMode, System::Object ^ nullValue, System::String ^ formatString, IFormatProvider ^ formatInfo);
public System.Windows.Forms.Binding Add (string propertyName, object dataSource, string dataMember, bool formattingEnabled, System.Windows.Forms.DataSourceUpdateMode updateMode, object nullValue, string formatString, IFormatProvider formatInfo);
override this.Add : string * obj * string * bool * System.Windows.Forms.DataSourceUpdateMode * obj * string * IFormatProvider -> System.Windows.Forms.Binding
Public Function Add (propertyName As String, dataSource As Object, dataMember As String, formattingEnabled As Boolean, updateMode As DataSourceUpdateMode, nullValue As Object, formatString As String, formatInfo As IFormatProvider) As Binding

参数

propertyName
String String String String

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

dataSource
Object Object Object Object

表示数据源的 ObjectAn Object representing the data source.

dataMember
String String String String

要绑定到的属性或列表。The property or list to bind to.

formattingEnabled
Boolean Boolean Boolean Boolean

若要格式化显示的数据,则为 true;否则为 falsetrue to format the displayed data; otherwise, false.

nullValue
Object Object Object Object

如果数据具有此值,则绑定属性设置为 DBNullWhen the data source has this value, the bound property is set to DBNull.

formatString
String String String String

一个或多个格式说明符,指示如何显示值One or more format specifier characters that indicate how a value is to be displayed

formatInfo
IFormatProvider IFormatProvider IFormatProvider IFormatProvider

重写默认格式设置行为的 IFormatProvider 的实现。An implementation of IFormatProvider to override default formatting behavior.

返回

新创建的 BindingThe newly created Binding.

异常

propertyName 给出的属性在该控件上不存在或者为只读。The property given by propertyName does not exist on the control or is read-only.

-or- 数据源中不存在指定的数据成员。The specified data member does not exist on the data source.

-or- 指定的数据源、数据成员或控件属性与集合中的另一个绑定相关联。The data source, data member, or control property specified are associated with another binding in the collection.

注解

调用方法会引发CollectionChanged事件。 AddCalling the Add method raises the CollectionChanged event.

适用于