使用EF 4,C#WinForms和Northwind數據庫,我將數據網格綁定到訂單實體,然後在運行時我創建了一個新的Comboboxcolum。DataGrid與Combobox列 - AddNew錯誤
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);
}
與上面的代碼,我成功地更改值並在DataGridView刪除行,但無法通過點擊「+」按鈕添加新行(新增),錯誤:「datagridviewcombocell不是有效值「。請問有什麼想法嗎?
在「+」按鈕的點擊事件上運行什麼代碼?錯誤發生在哪一行? –
databindingNavigator添加按鈕沒有額外的代碼,編譯器沒有指定行號 –