dgv automatically refreshing EVERYTHING? Why? BindingList? BindingSource??


Dec 21, 2012
Programming Experience
I was looking into iNotifyPropertyChanged so I set up a separate test project and checked it out.

I went to the VB program I've been playing with and set a button to set a property value to itself and set a BreakPoint for that Property in my Class so I could see it do its Get/Set thing because I wanted to know that would trigger it (that it wasn't smart enough to skip it because I was setting a value equal to itself), and it worked as expected. It did its Get/Set thing as I stepped through it and goes back to my application.

So now I've got my application running in Debug mode, and after about 1-2 seconds it automatically goes back to my class and starts getting property values for every item which is displayed in the DataGridView -BUT, it doesn't go anywhere else so I can see what triggered it. I step through the whole thing and when its finished I'm back at my application. I changed my button to set the property value to "gobblegobble" instead of itself, and I see the same behavior.

My application has a class consisting of normal data properties, nothing fancy.
I have a ClassCollection that inherits BindingList(Of myclass) with nothing fancy.
I have a BindingSource(bs) with a DataSource of ClassCollection.
I have a BindingNavigator(bn) with a BindingSource of bs.
I have a DataGridView(dgv) with a DataSource of bs.

Can someone PLEASE explain to me what is triggering the refresh of the DataGridView? I've searched my code for dgv.refresh() and it's not happening, and even if it was I would see it while stepping through the code. I don't have any paint or focus or mouseover events in my Form which is displaying the DataGridView.

Regarding ICancelAddNew, MSDN says: "The newer model supports a more robust data-binding scenario through the generic BindingList(Of T) class, which implements the IBindingList and ICancelAddNew interfaces. In this case, the transactional support is managed by the BindingList(Of T) collection directly."
(ICancelAddNew Interface (System.ComponentModel))

Also, regarding IRaiseItemChangedEvents, MSDN says: "You rarely need to implement the IRaiseItemChangedEvents interface. However, for performance purposes, your data source should implement IRaiseItemChangedEvents if it provides the functionality described previously, and your data source is interacting with the BindingSource component, because this functionality is built into the BindingSource."
(IRaiseItemChangedEvents Interface (System.ComponentModel))

?? Does this mean dgv is refreshing itself because BindingList inherenly knows to do it when a property value changes or because the BindingSource knows to do it when a property value changes?? Either way, why is it refreshing EVERYTHING on the DataGridView?

My whole point of checking out iNotifyPropertyChanged is because I have an image property in my class and an image column on dgv. I have an imagepath property in my class which stores the path to the image on the hard drive, and I thought I could tell the image property to create a new image from a filestream if the imagepath property changed. But if it's refreshing automatically I don't want it to do it every time. I get that I can do If Not m_MyImage = value the m_MyImage = New Image..., but it just seams crazy that so much refreshing is going on??

I don't get it??
Top Bottom