Datagridview with Comboboxcolumn using Entity Framework 4, C# in Windows Forms
I'm trying to populate a datagridview with Combobox column using the Northwind EF classes Orders and Customers. I used the following code to fill the unbound DataGridViewcomboColumn with customers names, to make possible the quick change of customer name while orders are displayed in the datagridview.
NorthwindEntities nw;
private void Form1_Load(object sender, EventArgs e)
{
nw = new NorthwindEntities();
ordersBindingSource.DataSource = nw.Orders;
DataGridViewComboBoxColumn CustomerName = new DataGridViewComboBoxColumn()
{
HeaderText="Name",
DataPropertyName = "CustomerID",
DataSource = nw.Customers.Execute(MergeOption.AppendOnly),
ValueMember = "CustomerID",
DisplayMember = "CompanyName"
};
}
With the above code the combocolumn stay empty when orders are displayed in the datagrid. Have I made any mistake, please help …