sthomaso@phmining.com
New member
- Joined
- Apr 9, 2007
- Messages
- 1
- Programming Experience
- 10+
I'm of the opinion that users should be able to TEMPORARILY have invalid data in a bound control. To enable this, I set Form.AutoValidate to EnableAllowFocusChange so they can leave a control even if there is invalid data. I bind these controls to an object that implements IDataErrorInfo & INotifyPropertyChanged, with property procedures like this:
Now let's say I enter an "a" into a textbox bound to this property, then I tab out of the textbox into another bound control, edit it, and then leave THAT control, too. This causes the controls to be refreshed with the value of the properties, which means that my invalid "a" gets changed to zero, the value of _x.
My question is: How can I set things up so the invalid "a" gets left in the control until the user decides to re-enter it and change the value?
---scott
VB.NET:
Private _x As Double
Public Property X() As Double
Get
Return _x
End Get
Set(ByVal value As Double)
If _x <> value Then
If value < 0 OrElse value > 10 Then
_item("X") = "X must be between 0 and 10!" ' For IDataErrorInfo.Item
Else
_item("X") = ""
_x = value
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("X"))
End If
End If
End Set
End Property
My question is: How can I set things up so the invalid "a" gets left in the control until the user decides to re-enter it and change the value?
---scott