利用EF 4, C# WinForms和北风数据库,我把一个数据网连接到命令实体,然后在运行时,我创建了一个新的Combo Boxcolum。
Entities NW;
private void Form1_Load(object sender, EventArgs e)
{
NW = new Entities();
BindingSource1.DataSource = NW.Orders;
DataGridViewComboBoxColumn CboCol = new DataGridViewComboBoxColumn()
{
HeaderText = "Customer",
DataPropertyName = " Customer ID",
DataSource = NW.Customers.Execute(MergeOption.AppendOnly),
ValueMember = "CustomerID",
DisplayMember = "CompanyName"
};
Datagriview1.Columns.Insert(1, CboCol);
}
with the above code, I succeeded to change values and delete rows in the datagridview, but could not add new rows by clicking on the "+" button (Add New), Error: "datagridviewcombocell is not a valid value". Is there any idea please ?