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 146261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:34:15+00:00 2026-05-11T08:34:15+00:00

I want to connect a BindingSource to a list of class objects and then

  • 0

I want to connect a BindingSource to a list of class objects and then objects value to a ComboBox.
Can anyone suggest how to do it?

public class Country {     public string Name { get; set; }     public IList<City> Cities { get; set; }      public Country()     {         Cities = new List<City>();     } } 

is my class and I want to bind its name field to a BindingSource which could be then associated with a ComboBox

  • 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. 2026-05-11T08:34:15+00:00Added an answer on May 11, 2026 at 8:34 am

    As you are referring to a combobox, I’m assuming you don’t want to use 2-way databinding (if so, look at using a BindingList)

    public class Country {     public string Name { get; set; }     public IList<City> Cities { get; set; }     public Country(string _name)     {         Cities = new List<City>();         Name = _name;     } } 

    List<Country> countries = new List<Country> { new Country('UK'),                                       new Country('Australia'),                                       new Country('France') };  var bindingSource1 = new BindingSource(); bindingSource1.DataSource = countries;  comboBox1.DataSource = bindingSource1.DataSource;  comboBox1.DisplayMember = 'Name'; comboBox1.ValueMember = 'Name'; 

    To find the country selected in the bound combobox, you would do something like: Country country = (Country)comboBox1.SelectedItem;.

    If you want the ComboBox to dynamically update you’ll need to make sure that the data structure that you have set as the DataSource implements IBindingList; one such structure is BindingList<T>.


    Tip: make sure that you are binding the DisplayMember to a Property on the class and not a public field. If you class uses public string Name { get; set; } it will work but if it uses public string Name; it will not be able to access the value and instead will display the object type for each line in the combo box.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to connect to Sql server and running some sql queries. How can
I want to connect Microsoft Access with Turbo C++. How can I do that?
I want to connect a database that is located on centralized server. How can
I want to connect to a server using HTTP, send a string to it
I want to connect joomla 2.5 to a Postgresql database. How can I do
I want to connect my log4j.xml with log4j.xsd (xml schema). Project don't have any
I want to connect my rails 3 application to firebird database. I have followed
I want to connect a single ForeignKey to two different models. For example: I
I want to connect from home using SQL Server 2005 to another PC. I
I want to connect to DB2 from excel macro...This is my code, but it

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.