예 : 양식에 Contact 개체가 있습니다 (아래 참조). BindingSource의 데이터 소스를 Contact.Addresses 속성으로 설정할 수 있습니까?BindingSource의 DataDource가 양식의 개체이고 양식의 개체가 될 수 있습니까?
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
}
감사 앤서니
귀하의 질문 - 당신은 컬렉션에 대한 필요없이 하나의 항목에 쉽게 바인딩 할 수 있습니다. –