CurrencyManager.ResumeBinding CurrencyManager.ResumeBinding CurrencyManager.ResumeBinding CurrencyManager.ResumeBinding Method

定义

继续数据绑定。Resumes data binding.

public:
 override void ResumeBinding();
public override void ResumeBinding ();
override this.ResumeBinding : unit -> unit
Public Overrides Sub ResumeBinding ()

示例

下面的代码示例演示如何使用 ResumeBinding 方法。The following code example demonstrates how to use the ResumeBinding method.

void button4_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
{
   try
   {
      BindingManagerBase^ myBindingManager2 = BindingContext[ myDataSet, "Customers" ];
      myBindingManager2->ResumeBinding();
   }
   catch ( Exception^ ex ) 
   {
      MessageBox::Show( ex->Source );
      MessageBox::Show( ex->Message );
   }
}
private void button4_Click(object sender, EventArgs e)
{
   try
   {
      BindingManagerBase myBindingManager2=BindingContext [myDataSet, "Customers"];
      myBindingManager2.ResumeBinding();
   }
   catch(Exception ex)
   {
      MessageBox.Show(ex.Source);
      MessageBox.Show(ex.Message);
   }
}
Private Sub button4_Click(sender As Object, e As EventArgs)
   Try
      Dim myBindingManager2 As BindingManagerBase = BindingContext(myDataSet, "Customers")
      myBindingManager2.ResumeBinding()
   Catch ex As Exception
      MessageBox.Show(ex.Source.ToString())
      MessageBox.Show(ex.Message.ToString())
   End Try
End Sub 'button4_Click

注解

SuspendBindingResumeBinding允许在一个简单的数据绑定方案中使用临时挂起和恢复的两种方法。SuspendBinding and ResumeBinding are two methods that allow the temporary suspension and resumption of in a simple data binding scenario. 如果必须允许用户对数据字段进行一些编辑之前进行验证,则通常会挂起数据绑定。You would typically suspend data binding if the user must be allowed to make several edits to data fields before validation occurs. 例如,如果必须将一个字段更改时根据第二个,但验证第一个字段会导致将在错误中的第二个字段。For example, if one field must be changed in accordance with a second, but where validating the first field would cause the second field to be in error.

备注

使用SuspendBinding防止更改推送到数据源之前ResumeBinding调用但不会阻止数据源中的更改会影响在绑定的控件。Using SuspendBinding prevents changes from being pushed into the data source until ResumeBinding is called but does not prevent changes in the data source from affecting the bound controls. 使用如下所示复杂数据绑定的控件DataGridView控件,如基于更改事件其值更新ListChanged事件。Controls that use complex data binding, such as the DataGridView control, update their values based on change events such as the ListChanged event. 调用此方法不会阻止这些事件的发生。Calling this method will not prevent these events from occurring. 出于此原因,SuspendBindingResumeBinding设计用于简单绑定控件,如TextBoxFor this reason, SuspendBinding and ResumeBinding are designed for use with simple-bound controls, such as a TextBox. 或者,您可以使用这些方法在复杂绑定方案中,则禁止显示如果ListChanged通过设置事件RaiseListChangedEvents属性设置为falseAlternatively, you can use these methods in a complex binding scenario if you suppress ListChanged events by setting the RaiseListChangedEvents property to false.

适用于

另请参阅