日期:2014-05-17  浏览次数:21006 次

怎么让ComboBox选中Items的某一项
我在DataGridView添加了一列ComboBox,并设置了它的DataSource。现在这一列的ComboBox都有了选项,怎么在程序里设置ComboBox选中某一项呢?
((DataGridViewComboBoxCell)row.Cells["DBCol"]).Value = “value”;
 这句话没起作用呢?

------解决方案--------------------

            DataGridViewComboBoxCell dc=new DataGridViewComboBoxCell();
            dc.Items.Add("test1");
            dc.Items.Add("test2");
            dc.Value = "test2";//这一句 

            this.dataGridView1.Columns.Add("c1","h1");
            this.dataGridView1.Rows.Add();
            this.dataGridView1.Rows[0].Cells[0]= dc;

------解决方案--------------------
调试看一下Value是哪一项的的属性。