为DataGridView组合框设置选定的项目失败
我有混乱的设置/获取组合框内的选定索引。为DataGridView组合框设置选定的项目失败
this.Parameter.DataSource = lambdacat.Dict();
{
foreach (DataGridViewRow row in LimView.Rows)
{
//((ComboBox)row.Cells[1]) ???
}
}
是的,这不工作:)
谢谢
您可以使用
(row.Cells[1] as DataGridViewComboBoxCell).Value == yourvalue;
,并获得选择的值作为
(row.Cells[1] as DataGridViewComboBoxCell).FormattedValue
要设置一个默认的选定值
(row.Cells[1] as DataGridViewComboBoxCell).Value =(row.Cells[1] as DataGridViewComboBoxCell).Items[yourneededindex]
已经有了一个字符串数组那里,如果yourvalue是它不字符串”检索相同t工作:( – Cynede 2011-04-26 07:45:10
如果你想添加数组的项目使用**(row.Cells [1]作为DataGridViewComboBoxCell).Items.Add(arrayval)** while循环数组 – V4Vendetta 2011-04-26 08:00:14
我想选择,项目已添加。 – Cynede 2011-04-26 08:13:44
您可以通过设置** **值单元格的设定值,并通过使用** ** FormattedValue的我 – V4Vendetta 2011-04-25 13:41:02