Two-way binding for DataGridView
I use DataGridView which is bound to the collection of objects which implement INotifyPropertyChanged interface. So, DataGridView is updated properly whenever properties of objects are changed (they are changing constantly taking their values from a device through a serial port).
The challenge is that I need two-way binding. But when I start editing DataGridView manually, when PropertyChang开发者_开发问答ed event is raised for currently editing object, I get the following InvaliedOperationException: "Cross-thread operation not valid: Control 'dataView' accessed from a thread other than the thread it was created on".
The question is: what strategy I can use to allow editing values and displaying them simultaneously in the DataGridView control?
Just a suggestion , you can use the BackgroundWorker class and use the DoWork to perform the data binding. Hope this helps.
精彩评论