DataBinding和表单结束事件

时间:2014-08-01 02:28:30

标签: .net vb.net binding

我有一个文本框的绑定对象,如下所示

Private withevents m_ShortNameBinding As Binding 

使用BindingSource,我将ShortName属性绑定到文本框,如下所示

m_ShortNameBinding = txtShortName.DataBindings.Add("Text", m_SampleSource, "ShortName", True, DataSourceUpdateMode.OnPropertyChanged)

我还处理了BindingComplete事件,如下所示

Private Sub m_ShortNameBinding_BindingComplete(sender As Object, e As BindingCompleteEventArgs) Handles m_ShortNameBinding.BindingComplete
        If Not e.BindingCompleteState = BindingCompleteState.Success Then
            ErrorProvider.SetError(txtShortName, e.ErrorText)
        End If
End Sub

通过上述方式,我尝试验证文本框不应该捕获超过8个字符。它完美无瑕。

除非绑定状态是成功,否则我不允许我关闭表格。如何在关闭表格时跳过验证或者给我一些其他方法来实现相同的目标?

...谢谢

0 个答案:

没有答案