Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. INotifyPropertyChanged works fine with a DataGridView, but not with a single databound textbox. Why ?

INotifyPropertyChanged works fine with a DataGridView, but not with a single databound textbox. Why ?

Scheduled Pinned Locked Moved Visual Basic
questionannouncement
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    David Mujica
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups