tags:

views:

124

answers:

2

C# How do I use an even to get my GUI update on change of an object?

I have a GUI program that creates an object and displays the object in a data grid through reflection.

When the user updates the information I want to be able to verify the new information and send feedback to the user. I have a method that does the verification of the information, I just need to figure out how to update the GUI with the new information.

thx.

A: 

Perhaps you could be more specific or show some code, but check that each Column Object of the .Net Datagrid has a property named DataPropertyName, which binds by reflection to the property of your objects, it should work.. Other thing is to implement the INotifyPropertyChanged on your objects, and Refresh the Grid on the PropertyChanged event.

jmayor
+1  A: 

Another general approach would be to support IObservable on your object, and IObserver on any classes (such as user interface elements) that wish to be notified of changes to your object. You can have any number of observers of changes on your object. It's a little more work than the "out of the box" data binding on controls such as data grids, but I would say more flexible.

NeilDurant