Note that there are some explanatory texts on larger screens.

plurals
  1. POCan the DataDource of a BindingSource be a property from and object on the form
    primarykey
    data
    text
    <p>For example: I have an Contact object on the form (see below). Can i set the datasource propery of the BindingSource to be the property Contact.Addresses.</p> <p>The class AddressCollection implements BindingList so there is no issue binding this when not encapsulated by the Contact class.</p> <pre><code>public class Contact : IComparable&lt;Contact&gt;, 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) &amp;&amp; (mSite.Container != null)) { mSite.Container.Remove(this); } Disposed(this, System.EventArgs.Empty); } public ISite Site { get { return mSite; } set { mSite = value; } } #endregion } </code></pre> <p>Thanks Anthony</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload