Populate Windows Forms ComboBox control using Entity Framework

saeed3164
 
on Mar 09, 2013 07:21 AM
10850 Views

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();

Download FREE API for Word, Excel and PDF in ASP.Net: Download
Mudassar
 
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";
        }
    }