There are a Dependency class with some properties
class Dependency:
{
public string ArtifactId { get; set; }
public string GroupId { get; set; }
public string Version { get; set; }
public Dependency() {}
}
and ProjectView class:
class ProjectView:
{
public string Dependency[] { get; set; }
...
}
I want to bind array of Dependencies from ProjectView class to DataGridView.
class Editor
{
private readonly ProjectView _currentProjectView;
... //I skipped constructor and other methods
private void PopulateTabs()
{
BindingSource source = new BindingSource {DataSource = _currentProjectView.Dependencies, AllowNew = true};
dataGridViewDependencies.DataSource = source;
}
}
But when I'm binding like that, then exception occurs (AllowNew can only be set to true on an IBindingList or on a read-write list with a default public constructor.), because _currentProjectView.Dependencies is array, and it can't be able to add new items. There is solution is convert to list, but it is not convenient, because it's just copy and lost reference to origin array. Is there solution of this problem? How to bind properly array to datagridview? Thanks.