INotifyPropertyChanged works fine with a DataGridView, but not with a single databound textbox. Why ?
-
I've created a class which Implements the INotifyPropertyChanged event and raises that event when a data member in the class is changed. On my form, (form3), I have: 1) BindingSource 2) BingingSourceNavigator 3) DatagridView 4) Textbox boound to the "LastName" datamember of the BadgeHolder class 5) A button which sets the first occurrence of LastName in the BindingSource Datasource to "Smith" When I click the button, the DataGridView is automatically updated with the value of Smith. Cool ! Why doesn't the Textbox get the update ? If I move to the next record using the BindingSourceNavigator button, then I navigate back to the first record, the Textbox has the value of "Smith". Which is correct. Why doesn't the Textbox automatically update like the DataGridView since they are both connected to the same BindingSource ? :confused: Thanks.
Public Class BadgeHolder
Implements INotifyPropertyChanged Public Event PropertyChanged As PropertyChangedEventHandler \_ Implements INotifyPropertyChanged.PropertyChanged
{blah, blah more class stuff ...}
Public Class FORM3
Private Sub FORM3\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.BadgeHolderBindingSource.DataSource = BadgeHolder.FILL Me.DataGridView1.DataSource = Me.BadgeHolderBindingSource Me.TextBox1.DataBindings.Add("Text", Me.BadgeHolderBindingSource.DataSource, "LastName", False, \_ DataSourceUpdateMode.OnPropertyChanged) End Sub Private Sub Button1\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim BHList As BindingList(Of BadgeHolder) = \_ CType(BadgeHolderBindingSource.DataSource, BindingList(Of BadgeHolder)) BHList(0).LastName = "Smith" End Sub
End Class