Data validation in WinForms using a BindingSource

I spent the better half of my workday trying to find a viable any solution for data validation in WinForms using a BindingSource. According to the Internet (tm) nobody has ever thought of this. The best bet so far is this tiny snippet from the .NET docs, which seems to suggest that “there is no built-in way, just do it yourself, idiot!”.

Private Sub AcceptOrReject(ByVal row As DataRow)
    If ValidateRow(row) Then
        row.EndEdit()
    Else
        row.CancelEdit()
    End If
End Sub

Private Function ValidateRow(ByVal thisRow As DataRow) As Boolean
    Dim isValid As Boolean = True
    Return isValid
End Function

What I really want to achieve is to receive more data than the “Column ‘Name’ does nto allow ‘nulls’” message in the NoNullAllowedException.

By Inhji * * * Permalink