Update on databound datagrid not updating

18-May-2016 13:19

I have a datagrid in my wpf application and I have a simple problem. Add(new Sort Description("Name", List Sort Direction. I have a generic list and I want to bind this collection to my datagrid data source every time an object is being added to the collection. In my case, I have a method that return the values for two columns that I have on my datagridview. But the datagrid still doesn't refresh after I insert a record. @user3222297 So, in that Method That Return List() you can build a List (List is a class) with all the items you need."Forces the control to invalidate its client area and immediately redraw itself and any child controls." Control.Refresh Method Observablecollection : Represents a dynamic data collection that provides notifications when items get added, removed, or when the whole list is refreshed.

update on databound datagrid not updating-53update on databound datagrid not updating-44update on databound datagrid not updating-36

It causes all of your data bound controls to check to see if their data has been updated and then refresh if [email protected], if you are using auto generated columns and you set the datasource to NULL it will clear the columns.

If I click on the changed cell, or minimize then maximize the window it updates properly, but I need it to happen automatically. ..I'd really like to avoid this as it makes the scrollbar pop back to the top, and means that I'd have to set my cell background colours again. I've tried Refresh (as well as refreshing the parent), Update, and Invalidate, but they're not doing what I need. MSDN should contract with Stack Overflow to do their code examples; Microsoft's leave a lot to be desired ("Here is one line of code that doesn't really help you...") It sounds as your Change Object notification is not triggered / handled correctly.

I had the same problem earlier, but in that situation I had to change the cell's background colour at the same time that the value changed. I've seen this problem mentioned on a few message boards, but haven't seen a working answer to it yet. I personally always use the Binding Source object when binding to a data Grid View.

That way if the user resizes a column it won't toss out their change on refresh. My recommendation: If you have ownership of the datasource, don't use a List. The Binding List has events that fire when items are added or changed, and the Data Grid View will automatically update itself when these events are fired.

just talks about the control redrawing, nothing to do with bindings unless I am very much mistaken!

It causes all of your data bound controls to check to see if their data has been updated and then refresh if [email protected], if you are using auto generated columns and you set the datasource to NULL it will clear the columns.

If I click on the changed cell, or minimize then maximize the window it updates properly, but I need it to happen automatically. ..I'd really like to avoid this as it makes the scrollbar pop back to the top, and means that I'd have to set my cell background colours again. I've tried Refresh (as well as refreshing the parent), Update, and Invalidate, but they're not doing what I need. MSDN should contract with Stack Overflow to do their code examples; Microsoft's leave a lot to be desired ("Here is one line of code that doesn't really help you...") It sounds as your Change Object notification is not triggered / handled correctly.

I had the same problem earlier, but in that situation I had to change the cell's background colour at the same time that the value changed. I've seen this problem mentioned on a few message boards, but haven't seen a working answer to it yet. I personally always use the Binding Source object when binding to a data Grid View.

That way if the user resizes a column it won't toss out their change on refresh. My recommendation: If you have ownership of the datasource, don't use a List. The Binding List has events that fire when items are added or changed, and the Data Grid View will automatically update itself when these events are fired.

just talks about the control redrawing, nothing to do with bindings unless I am very much mistaken!

and I'm not interested to use observable collection.