我正在使用Datagridview,部分由數據源填充,通過設置DataPropertyNames。 部分由我代碼填寫。 我有一個DataGridViewComboBoxColumn,其中單元格應該填充時,我點擊旁邊的按鈕。 單擊按鈕填充DataGridViewComboBoxCell的項目,但如果我單擊ComboBox,我無法打開它來選擇一個值。DataGridViewComboBoxCell中的新項目不顯示
(在函數結束時,我改變columnvalue以X作爲測試,能正常工作......)
代碼:
//add the combobox column
DataGridViewComboBoxColumn cellcol = new DataGridViewComboBoxColumn();
cellcol.Name = "Cell";
cellcol.ReadOnly = false;
dataGridView1.Columns.Add(cellcol);
//method that gets called when the button is clicked
private void getAllCells(List<ComponentRow> componentRows, int i)
{
//show all cells
CellFilter cf = new CellFilter();
cf.customerNr = libraryNr;
Cell[] cells = Service.Instance.Client.queryCells(cf, new QueryParam());
foreach (Cell c in cells)
{
((DataGridViewComboBoxCell)dataGridView1["Cell", i]).Items.Add(cells[0].cell_name);
}
cellsShownForComponents[i] = ShowedCells.ALL;
((DataGridViewTextBoxCell)dataGridView1["variants", i]).Value = "x";
}
*如果我點擊在組合框上,我無法打開它來選擇一個值* - >這意味着組合框根本沒有任何項目,也可能需要點擊組合框兩次,第一個是激活它,第二個是ac真的要放下它的名單。 –
組合框包含項目(我已通過調試進行檢查)。點擊兩次也不起作用。我確實在datagridview上實現了點擊事件處理程序,但由於它對其他單元格仍然是正常的,所以我不明白爲什麼它對於combobox列 – RazorEater