How should I bind my collection of T objects which implements an interface and adds more properties to a DataGrid? Here is an example:
// interface
public interface IPerson{
[DisplayName(@"FullName")]
string Name{ get; }
}
// implementation
public class Employee : IPerson{
[DisplayName(@"Net Salary")]
public int Salary {
get { return 1000; }
}
public string Name{
get { return "Foo"; }
}
// collection
SortableBindingList<IPerson> MyList { get; set }
...
...
MyList.Add(new Employee());
...
dataGridView.DataSource = MyList;
When I do this, it only binds Name but not Salary.
Is there any way to bind to both the properties (Name and Salary in this case)? Thanks.