I have an error provider on my form that has its datasource bound to a collection of Errors in my record class:
The validation is working as I expect, however the red blinking icon does not appear next to my form controls. My record implements IDataErrorInfo:
Public ReadOnly Property [Error] As String Implements IDataErrorInfo.Error
Get
If _Errors.Count > 0 Then
Return String.Format("The record cannot be saved because there are {0} errors", _Errors.Count)
Else
Return String.Empty
End If
End Get
End Property
''' <summary>
''' Gets an error message for the property with the given name
''' </summary>
''' <value></value>
''' <returns></returns>
Default Public ReadOnly Property PropertyError(fieldName As String) As String Implements IDataErrorInfo.Item
Get
If _Errors.ContainsKey(fieldName) Then
Return _Errors(fieldName).ToString
Else
Return String.Empty
End If
End Get
End Property
Any thoughts would be very much appreciated as I'm completely stuck.
The problem was caused by my adding the errors to the collection using the control names e.g. StaticBalancesOOSReasonValue" and then trying to retrieve them from the IDataErrorInfo.PropertyError method using the property names e.g. "StaticBalancesOOSReason". Now that's fixed the icons display.