2013-12-09 5 views
2

DataPropertyNames를 설정하여 데이터 소스로 부분적으로 채워진 Datagridview를 사용하고 있습니다. 부분적으로 코드에서 나를 채웠습니다. DataGridViewComboBoxColumn은 옆에있는 버튼을 클릭 할 때 셀을 채워야하는 곳입니다. 버튼을 클릭하면 DataGridViewComboBoxCell의 항목이 채워지지만 ComboBox를 클릭하면 열어서 값을 선택할 수 없습니다.DataGridViewComboBoxCell의 새 항목이 표시되지 않습니다.

//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"; 
     } 
+0

을 편집 할 수 없습니다해야 다른 모든 열 사용자를위한 내 comboboxcolumn

ReadOnly = false 

의 DataGridView에

ReadOnly = false 

에 대한 을 * 내가 클릭하면 ComboBox에서 값을 선택하기 위해 열 수 없습니다. * -> 즉, 콤보 상자에 항목이 전혀 없으며 ComboBox를 두 번 클릭해야한다는 것을 의미합니다. 첫 번째는 활성화하고 두 번째는 AC입니다. 순식간에 그 명부를 삭제하십시오. –

+0

콤보 상자에 항목이 들어 있습니다 (디버깅을 통해 확인했습니다). 두 번 클릭해도 작동하지 않습니다. 나는 click-eventhandler가 datagridview에 구현되어 있지만 다른 셀에서는 여전히 정상적으로 동작하므로 comboboxcolumn에 대해 정상적으로 작동하지 않는 이유는 알 수 없습니다. – RazorEater

답변

2

난 내 자신의 질문에 답변 해 드리겠습니다 :

코드 (함수의 끝에서 난 ...이 잘 작동 테스트로 X에 columnvalue 변경). 문제는 내 datagridview가 읽기 전용이라는 것입니다. readonly comboboxcolumns를 열 수 없습니다. 나는 이런 식으로 고정 :

ReadOnly = true 
+0

감사합니다. 내가 EF6에 대해 냄새를 맡고 놀고있을 때 저의 하루를 저축했습니다. 힘내 친구 야! –

관련 문제