I have a simple application which uses a BindingList<(Person)>, people, to store information about employees (Windows Forms). Person has several properties such as Name, DateOfBirth, etc and implements INotifyPropertyChanged.
The BindingList<(Person)>, people, is bound to a binding source. A DataGridView control is bound to this source, and as expected property changes are updated on the DataGridView. For example, when I change the age of a person the DataGridView updates immediately.
My problem occurs when I use the same binding source other controls. I have the text property of a text box bound to Person.Name, using the same binding source as the DataGridView. Changes to the Person.Name 开发者_Go百科property update on the DataGridView, but not to the text box.
How can I make the text box update, like the DataGridView, when a property changes?
Chris
Just quickly, this is untested, it probably needs to be handled by a Dispatcher. Try using the following in place of your TextBox
public class DispatchedTextBox : TextBox
    {
        DispatchEvent _propertyChanged = new DispatchEvent();
        protected override void OnPropertyChanged(PropertyChangedEventArgs e)
        {
            this._propertyChanged.Fire(this, e);
        }
        protected override event PropertyChangedEventHandler PropertyChanged
        {
            add { this._propertyChanged.Add(value); }
            remove { this._propertyChanged.Remove(value); }
        }
    }
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论