Ok, I have my custom class:
public class FileItem : INotifyPropertyChanged
{
int id=0;
string value="";
public int Id
{
get { return id; }
set { id = value; Changed("Id"); }
}
public string Value
{
get { return value; }
set { this.value = value; Changed("Value"); }
}
public event PropertyChangedEventHandler PropertyChanged;
void Changed(string name)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
public BindingList<FileItem> FilesystemEntries = new BindingList<FileItem>();
And I have DatagridView1 with DataSource set to FilesystemEntries:
binding.DataSource = FilesystemEntries;
Already I can Add and remove rows - these chnages are reflected on collection. However, Value and Id are not saved into bidning list when i change them in DataGridView, id is always 0 and value is "".
How can I make this work? Do I need to implement some interface to FileItem to allow editing properties?
ReadOnly of DGV is set to false, same to all columns. Editing, Deleting and Changing are enabled.