Populate Windows Forms ComboBox control using Entity Framework

Last Reply on Mar 09, 2013 10:43 PM By Mudassar

Posted on Mar 09, 2013 07:21 AM

HI,
 
I tried to show list of name on cmbobox
 

this is the code(query
var query = (from p in dbhome.Stores select new { p.FNameware,p.id }).ToList();
Cbox.DataSource = query.ToList();

Posted on Mar 09, 2013 10:43 PM

Using the Northwind Database Customers Entity. I gave created the following sample

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            NorthwindEntities entities = new NorthwindEntities();
            cmbCustomers.DataSource = (from customer in entities.Customers
                                       where customer.City == "London"
                                       select customer);
            cmbCustomers.DisplayMember = "ContactName";
            cmbCustomers.ValueMember = "CustomerId";
        }
    }

 

I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html