例: フォームに Contact オブジェクトがあります (以下を参照)。BindingSource のデータソース プロパティを Contact.Addresses プロパティに設定できますか。
クラス AddressCollection は BindingList を実装するため、Contact クラスによってカプセル化されていない場合、これをバインドする問題はありません。
public class Contact : IComparable<Contact>, IComponent
{
#region Properties
private AddressCollection addresses = new AddressCollection();
private ContactNumberCollection contactNumbers = new ContactNumberCollection();
public int ContactId { get; set; }
public string Title { get; set; }
public string Forename { get; set; }
public string MiddleName { get; set; }
public string Surname { get; set; }
public string JobTitle { get; set; }
public DateTime DateAdded { get; set; }
public DateTime LastUpdate { get; set; }
public AddressCollection Addresses
{
get { return addresses; }
set { addresses = value; }
}
public ContactNumberCollection ContactNumbers
{
get { return contactNumbers; }
set { contactNumbers = value; }
}
#endregion
#region Constructors
public Contact()
{
DateAdded = DateTime.Now;
LastUpdate = DateTime.Now;
}
#endregion
public int CompareTo(Contact other)
{
return FullName.CompareTo(other.FullName);
}
#region IComponent Objects
private ISite mSite;
public event EventHandler Disposed;
public virtual void Dispose()
{
if ((mSite != null) && (mSite.Container != null))
{
mSite.Container.Remove(this);
}
Disposed(this, System.EventArgs.Empty);
}
public ISite Site
{
get
{
return mSite;
}
set
{
mSite = value;
}
}
#endregion
}
ありがとうアンソニー