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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:23:18+00:00 2026-05-20T08:23:18+00:00

I am using Entity Framework 4, I need to get WinForms to bind Customers

  • 0

I am using Entity Framework 4, I need to get WinForms to bind Customers and Quotes as a Master – Detail relationship.

I have a Quote table which I lay out as details view on a Windows Form.

The quote table has 3 foreign keys to the customer table. (fields CustomerId, SiteCustomerId, InvoiceCustomerId which all link to Id field in the Customer table).

On the form there are 3 Customer panels with the Customer Name fields in a ComboBox, and other Customer detail fields in textBoxes.

How do I wire up the combo boxes so that they display all the possible Customers in the drop down from the Customer table and have the correct Selected Value, and save to the correct CustomerId field in the Quote table.

My (bad) attempt:

     Context = new Entities();
        quoteBindingSource.DataSource = Context.Quote;
    customersBindingSource.DataSource = Context.Customers;

        comboBox1.DataSource = customersBindingSource;
                    comboBox1.DisplayMember = "Customer";
                    comboBox1.ValueMember = "Id";

                    comboBox1.DataBindings.Clear();
                    comboBox1.DataBindings.Add("SelectedValue", quoteBindingSource, "CustomerId");

comboBox9.DataSource = customersBindingSource;
            comboBox9.DisplayMember = "Customer";
            comboBox9.ValueMember = "Id";

            comboBox9.DataBindings.Clear();
            comboBox9.DataBindings.Add("SelectedValue", quoteBindingSource, "InvoiceCustomerId");

            comboBox6.DataSource = customersBindingSource;
            comboBox6.DisplayMember = "Customer";
            comboBox6.ValueMember = "Id";

            comboBox6.DataBindings.Clear();
            comboBox6.DataBindings.Add("SelectedValue", quoteBindingSource, "SiteCustomerId");
  • 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-20T08:23:18+00:00Added an answer on May 20, 2026 at 8:23 am

    thank you for your WinForms project version:) Well it occurs, that either something is wrong or we may have discovered a kind of a bug. In situations like that it is usually safer to assume that we lack some kind of knowledge. The solution is simple yet weird: in every Combobox you do:

    comboBox9.DataBindings.Add("SelectedValue", quoteBindingSource, "InvoiceCustomerId");
    

    What you should do to improve the situation with values coming back to old ones is:

    comboBox9.DataBindings.Add(new Binding("SelectedValue", quoteBindingSource, "InvoiceCustomerId",true));
    

    Now there is a question. Why ? When you look at the IntelliSense hint for the Add method of the DataBindings collection you see sth. like this:

    Creates a System.Windows.Forms.Binding using the specified control property name, data source and data member, and adds it to the collection

    Well in my humble opinion, after reading this description, the result of the two lines of code cited above should be pretty much the same. Why it is not ? Well let’s hope it is only our lack of knowledge, otherwise it is a bug:)

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

Sidebar

Related Questions

I am using the Entity Framework. I have a many to many relationship Articles
I am using Entity Framework with my website. To improve performance, I have started
I have a problem with the following Linq query using Entity Framework: from o
So, I am using the Linq entity framework. I have 2 entities: Content and
Using Entity Framework, I suddenly get this strange error after publishing my asp.net mvc
We are using Entity Framework 1.0. In some cases we need to explicitly open
I'm using entity framework to connect the database. I've a table(Let's call it File)
How would I write a query using entity framework where I need to make
Using : SQL Server 2008, Entity Framework I am summing columns in a table
I'm using Entity Framework O/R mapper from Microsoft and using entity classes (generated classes

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.