C# – Datagridview ComboBoxCell set default value

ccomboboxdatagridviewnet

I have a datagridview with lots of data, and when I add a new line, the first column's last row creates a new ComboBoxCell which contain four items. But I can't set the default value ("DropDown") for the combobox. Every time I must manually select "DropDown". What is the solution?

 DataGridViewComboBoxCell dgvCell = new DataGridViewComboBoxCell();
 dgv[1, dgv.Rows.Count - 1] = dgvCell;

 string[] controltype = {"DropDown", "CheckBoxList", "ListControl", "Tree" };
 dgvCell.DataSource = controltype;

Best Answer

private void dataGridView_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
    {
        e.Row.Cells[4].Value = "DropDown";
    }
Related Topic