首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

如何让ComboBox选中Items的某一项

2014-01-21 
怎么让ComboBox选中Items的某一项我在DataGridView添加了一列ComboBox,并设置了它的DataSource。现在这一列

怎么让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是哪一项的的属性。

热点排行