This relates to vb.net on vs2008
I have a form (in actual fact many forms) in which the fields are bound to the public properties of class I have created. For example let say it is a customer class object oCustomer of type clsCustomer.
In the Set section of property declaration I use the NotifyPropertyChanged("propertyname") command like this:-
This allows two way binding from my text box lets call it txtAddress4 and it works fine. The problem comes when I make a change to another property of clsCustomer from an event of txtAddress4 such as propertychanged or validating. Let say I update oCustomer.Address3. When I do this it seems to overwrite the change I have made to txtaddress4.text as soon as I tab to the next field - it seems to be overwriting it back from whatever is in the ocustomer.address4 prior to me amending it. This only happens if I try to update another property of the ocustomer object in a txtaddress4 event.
If I set m_NotifyOnPropertyChange = false first then I do not have this problem but this then causes issues with binding.
Has anyone else experienced this issue? Do you have a solution?
I have a form (in actual fact many forms) in which the fields are bound to the public properties of class I have created. For example let say it is a customer class object oCustomer of type clsCustomer.
In the Set section of property declaration I use the NotifyPropertyChanged("propertyname") command like this:-
VB.NET:
Public Class clsCustomer
Implements INotifyPropertyChanged
Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
Private m_NotifyOnPropertyChange As Boolean = True
Private mAddress4 as string = ""
Public Overridable Property Address4() As String
Get
Return mAddress4
End Get
Set(ByVal Value As String)
If mAddress4 <> Value Then
mAddress4 = Value
[B]NotifyPropertyChanged("Address4")[/B]
End If
End Set
End Property[/SIZE]
[SIZE=2]
[/SIZE][SIZE=2] Public Property _NotifyOnPropertyChange() As Boolean[/SIZE]
[SIZE=2] Get[/SIZE]
[SIZE=2] Return m_NotifyOnPropertyChange[/SIZE]
[SIZE=2] End Get[/SIZE]
[SIZE=2] Set(ByVal value As Boolean)[/SIZE]
[SIZE=2] m_NotifyOnPropertyChange = value[/SIZE]
[SIZE=2] End Set[/SIZE]
[SIZE=2] End Property
Public Sub NotifyPropertyChanged(ByVal PropertyName As String)
If Me.m_NotifyOnPropertyChange Then
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(PropertyName))
End If
End Sub
[/SIZE]
[SIZE=2]end class[/SIZE]
If I set m_NotifyOnPropertyChange = false first then I do not have this problem but this then causes issues with binding.
Has anyone else experienced this issue? Do you have a solution?