A List of Objects of a custom class. The class defines a ToString method.
A WinForms…form… with a DataGridView on it.
The list will change during the usage of the program.
What I want:
The Datagridview to show the list of strings created by Select’ing the List into the ToString method.
When the List of Objects updates, to be able to regenerate or update the DataGridView.
The rows in the DataGridView can be deleted by the user (which then triggers a reverse process to clean up the List of Objects)
What happens currently:
Depending on which odd convoluted 6-layer deep DataSource/BindingSource/BindingList/PickAnotherSolutionFromGoogle I use, I either get a blank row or a row with 2 columns, one of which just contains the length of the string.
Hey, have you tried looking at Google material 3 docs? That’s right, there are none. You have to use the material 2 ones, and even then, there’s plenty of components that still only have “to do” as content. At least Microsoft has excellent documentation.
If I understand this then one possibility is to set the DataSource (or whatever specifies where the data is) to null then set it again. It has been a while since I have done Windows Forms.
The solution Microsoft wants us to use is to make the List of Objects an ObservableCollection and to implement INotifyPropertyChanged for the properties in it. I agree that this stuff seems unnecessarily convoluted. The intent however is to make it automatic; that we do not need to regenerate the view.
If I understand then that is more of a matter of the database. After the database is updated (or maybe after the entity is updated) an ObservableCollection will trigger the relevant update of the view.
I am in a reverse situation. I use a WPF window to edit an entity and the corresponding grid is also updated but if the cancel button is clicked then the edit needs to be reversed. I will not get into details here since it does not help you.