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

  • SEARCH
  • Home
  • 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

Ask A Question

Stats

  • Questions 124k
  • Answers 124k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Are you running on OS 3.0? I saw the same… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer It looks like you need to register Apache::Session::Memcached with Apache::Session::Wrapper,… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer Use DATENAME or DATEPART: SELECT DATENAME(dw,GETDATE()) -- Friday SELECT DATEPART(dw,GETDATE())… May 12, 2026 at 1:19 am

Related Questions

We're working on an hospital information system that is being written on C# and
1) Where does the homepage of your website fit into controllers? I've seen some
You can pass a function pointer, function object (or boost lambda) to std::sort to
I have worked a bit with Django and I quite like its project/applications model

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.