1
我有一个DataGridView有一个ComboBox列。我填充此列的有型的项目列表场:DataGridViewComboBoxColumn - 下拉列表中的项目类型
DataGridViewComboBoxColumn fieldsColumn = argumentsDataGridView.Columns["field"] as DataGridViewComboBoxColumn;
foreach (Field field in SessionData.Fields)
fieldsColumn.Items.Add(field);
fieldsColumn.DisplayMember = "Name";
再经过一些用户的动作,我把一个价值在此列像这样的小区:
private void AddArgument(string argumentName, Field field)
{
int index = argumentsDataGridView.Rows.Count;
argumentsDataGridView.Rows.Add(new DataGridViewRow());
DataGridViewRow newRow = argumentsDataGridView.Rows[index];
newRow.Cells["nameArg"].Value = argumentName;
-> newRow.Cells["field"].Value = field;
}
如果我现在访问单元格的值,它是一个类型字段。如果我从组合中选择不同的项目,那么单元格的值将变成一个字符串。我该如何处理?我需要类型的项目。
你甚至如何得到这个工作?当我运行一个简单的测试时,我得到一个System.ArgumentException? – BFree 2009-02-23 14:32:32
你在哪里得到这个异常? – agnieszka 2009-02-23 14:43:52