c#datagridview组合框列错误

时间:2015-04-05 06:51:17

标签: c# sql-server datagridview combobox

我收到此错误:“DataGridViewComboBoxCell值无效。” 这是我的代码

 DataGridViewComboBoxColumn dgvcombo = new DataGridViewComboBoxColumn();
                            dgvcombo.ValueType = typeof(decimal);
                            dgvcombo.Name = Name;
                            dgvcombo.DataPropertyName = colname;
                            dgvcombo.DataSource = dtsource;
                            dgvcombo.DisplayMember = DisplayMember;
                            dgvcombo.ValueMember = ValueMember;
                            dgvcombo.Visible = Visible;
                            dgvcombo.Width = width;
                            DataGridView.Columns.Add(dgvcombo);

每次为所有行生成Combobox列时,我都会收到此错误

1 个答案:

答案 0 :(得分:0)

你可以试试这个

DataGridViewComboBoxColumn dgvcombo =
            dataGridView1.Columns[0] as DataGridViewComboBoxColumn;

或者你可以试试这个 link也是