1

我知道这是非常基本的,但我不能让它为我的生活工作。

我有一个文本框 (PassportField) 和一个复选框 (PassportCheckBox),它们绑定到我的班级的 (Person) 属性。Person 类实现了 INotifyPropertyChanged 和 IDataErrorProvider 接口。

这是我的绑定控件源代码:

Private WithEvents _PersonBindingSource As New Windows.Forms.BindingSource

Public Sub InitialiseBinding(ByVal person As Person)

  Me._PersonBindingSource.DataSource = person
  Me.PassportCheckBox.DataBindings.Add("Checked", _DoctorClinicBindingSource, "Passport", True,  Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)
  Me.PassportField.DataBindings.Add("Text", _DoctorClinicBindingSource, "PassportText", True, Windows.Forms.DataSourceUpdateMode.OnPropertyChanged, String.Empty)

 End Sub

我需要验证我的文本框,这样,如果选中了复选框,则文本框不能留空,这是通过针对文本框的错误提供程序来指示的。

因此,如果用户选中复选框,并且只是在不输入任何数据的情况下跳出文本框(即留空),则应该触发 INotifyPropertyChanged(我知道这可能不起作用,因为属性并没有真正改变)

目前验证在我的业务对象中。

有人可以对此有所了解吗?

4

0 回答 0