Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 196623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:47:00+00:00 2026-05-11T16:47:00+00:00

For example: I have an Contact object on the form (see below). Can i

  • 0

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.

The class AddressCollection implements BindingList so there is no issue binding this when not encapsulated by the Contact class.

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
}

Thanks Anthony

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T16:47:00+00:00Added an answer on May 11, 2026 at 4:47 pm

    In short, yes you can. However, if you need to change the contact you may want to set the DataSource to the contact (or the list of contacts) and use the DataMember to “Addresses”.

    Here’s a simplified example showing such binding. If I have missed your point, please clarify:

    using System;
    using System.ComponentModel;
    using System.Windows.Forms;
    class AddressCollection : BindingList<Address>
    {
        public void Add(string line1, string zip)
        { // just for convenience
            Add(new Address { Line1 = line1, Zip = zip});
        }
    }
    
    class Address
    {
        public string Line1 { get; set; }
        public string Zip { get; set; }
    
        public override string ToString()
        {
            return Line1;
        }
    }
    class Contact
    {
        public string Name { get; set; }
        private readonly AddressCollection addresses = new AddressCollection();
        public AddressCollection Addresses { get { return addresses; } }
        public override string ToString()
        {
            return Name;
        }
    }
    
    static class Program
    {
        [STAThread]
        static void Main()
        {
            BindingList<Contact> contacts = new BindingList<Contact>
            {
                new Contact { Name = "Fred", Addresses = { {"123 Some road", "AB1"}}},
                new Contact { Name = "Barney", Addresses = { {"456 A Street", "CD2"}, {"789 The Lane", "EF3"}}}                
            };
            BindingSource bs = new BindingSource(contacts, "");
    
            Form form = new Form { 
                Controls = {
                                    new DataGridView { Dock = DockStyle.Fill, DataSource = bs, DataMember = "Addresses" },
                    new ComboBox { Dock = DockStyle.Top, DataSource = bs, DisplayMember = "Name" },
                    new TextBox { Dock = DockStyle.Bottom, DataBindings = { {"Text", bs, "Addresses.Zip"}}}
                }
            };
            Application.Run(form);
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is often situation, but here is latest example: Companies have various contact data
I have example of code below. <script type=text/javascript src=assets/scripts/somescript.php>. </script> So, will my browser
For example I have a simple class like public class Person{ public int Age
When picking out contact details, is there a built in domain class they can
I am practising c# with a phonebook example using Hashtable. I have a class
So, I have a object with structure similar to below, all of which are
I have the following PHP Classes class.property.php class.location.php class.amenity.php class.category.php all four classes handles
I'm using the Silverlight UnitTest framerwork does anyone have a good example have how
Example: You have a shortcut s to SomeProgram in the current directory. In cmd.exe
Example I have Person , SpecialPerson , and User . Person and SpecialPerson are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.