开发者

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

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 us开发者_如何学Cer 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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜