2014-10-27 53 views
0
private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e) 
{ 
    if (dataGridView1.CurrentCell.ColumnIndex==0) 
    { 

     dataGridView1.BeginEdit(true); 
     comboBox1.Visible = true; 
     comboBox1.Location = dataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true).Location; 
     comboBox1.Size = dataGridView1.CurrentCell.Size; 

     comboBox1.Focus(); 
    } 
} 

操作不工作把System.Windows.Form.ComboBox中的DataGridView和在上面的代碼組合框下拉財產鍵盤

+0

_not working_是什麼意思?你得到任何異常或錯誤信息? – 2014-10-27 08:49:52

+0

沒有錯誤,組合框下拉不擴展 – Ranjeet 2014-10-27 09:37:10

+0

(http://stackoverflow.com/questions/26583829/put-the-system-windows-form-combobox-in-datagridview-operate-by-keyboard)這個鏈接包含完整的代碼我寫了 – Ranjeet 2014-10-27 09:38:14

回答

0

您可以設置一個新的「組合框行」使用下面的代碼:

CODE

 DataGridViewCheckBoxColumn chk = new DataGridViewCheckBoxColumn(); 
     dataGridView1.Columns.Add(chk); 
     chk.HeaderText = "Check Data"; 
     chk.Name = "chk"; 
     dataGridView1.Rows[2].Cells[3].Value = true; 

我希望這能解決您的問題!祝你今天愉快。

+0

我想把Combobox不CheckBox – Ranjeet 2014-10-31 17:09:55