Datagridview ComboBoxCell设置默认值? [英] Datagridview ComboBoxCell set default value?

查看:1130
本文介绍了Datagridview ComboBoxCell设置默认值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个datagridview有很多数据,当我添加一个新行,第一列的最后一行创建一个新的ComboBoxCell包含四个项目。但我不能为组合框设置默认值(DropDown)。每次我必须手动选择DropDown。什么是解决方案?

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;


推荐答案

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

这篇关于Datagridview ComboBoxCell设置默认值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆