C # grid binding not updating

I have a grid attached to a collection. For some reason that I donโ€™t know, now that Iโ€™m doing some action on the grid, the grid is not updating.

Situation: When I click the button in the grid, it increases the value, which is on the same line. When I click, I can debug and see the increase in value, but the value does not change in the grid. BUT , when I click the button, minimize and restore the windows, the value is updated ... what do I need to do to update the value, as it was before?

UPDATE This is NOT SOLVED, but I accepted the best answer here.

It is not resolved because it works as usual when data comes from the database, but not from the cache. Objects are serialized and drop the process when the event is lost. That's why I am building them back, and it works for what I know, because I can interact with them, but it does not seem to work for updating the grid for an unknown reason.

+2
source share
3 answers

In order for the binding to be bi-directional, from the control element to the data source and the data source for managing the data source, it is necessary to implement notification events about changing properties in one of two possible ways:

  • Implement INotifyPropertyChanged interface and raise the event when you change the properties:

    public string Name 
    {
      get
      {
        return this._Name;
      }
      set
      {
        if (value != this._Name)
        {
            this._Name= value;
            NotifyPropertyChanged("Name");
        }
      }
    }
    
  • , , . PropertyNameChanged:

    public event EventHandler NameChanged;
    
    public string Name 
    {
      get
      {
        return this._Name;
      }
      set
      {
        if (value != this._Name)
        {
            this._Name= value;
            if (NameChanged != null) NameChanged(this, EventArgs.Empty);
        }
      }
    }
    

    * , .

+2

, DataBind .

0

I use a BindingSource object between my collection and my grid. Usually I do not need to call anything.

0
source

Source: https://habr.com/ru/post/1697399/


All Articles