DataGridView(like most direct list-based bindings) can only be bound to the immediate properties of a row element. Could you create a facade object for this? that is, a class that takes an instance and returns the name as a direct property:
public string Name {
get {return innerObject.Name;}
set {innerObject.Name = value;}
}
Alternatively, can you create a new object? For example, data bindings work (at least read-only) with anonymous types:
grid.DataSource = originalData.Select(x=>
new {x.Key, Name = x.Field.Name}).ToList();
Finally, you can hack in ComponentModelto flatten the model at runtime, but it really is not suitable for this.
source
share