次の構造を持つオブジェクトのコレクションがあります。
public class Parent
{
public string Title { get; set; }
public string Guid { get; set; }
}
public class Child:Parent
{
public string Description { get; set; }
}
List<Parent> collection ;
collection = new List<Parent>();
collection.Add(new Parent());
collection.Add(new Parent());
collection.Add(new Child());
collection.Add(new Child());
collection.Add(new Parent());
したがって、一部の要素は親タイプからのものであり、一部は子タイプからのものです(コレクション内のオブジェクト間に継承関係があります)。
次のバインディングを使用しました。
txtTitle.DataBindings.Add("Text", _BindingSource, "Title");
txtGuid.DataBindings.Add("Text", _BindingSource, "Guid");
txtDescription.DataBindings.Add("Text", _BindingSource,"Description");
最初の2つのバインディングは明らかに正常に機能します。しかし、データを正しく表示するには、3番目のものをどうすればよいですか?