我试图以编程方式将一行插入DataGridView。列是:
Column1组合框
Column2文本框
这是我的代码。 Column1使用DataGridView的内置DataSource绑定到表。
DataGridViewRow row = new DataGridViewRow();
DataGridViewComboBoxCell __action1 = new DataGridViewComboBoxCell();
DataGridViewTextBoxCell __site = new DataGridViewTextBoxCell();
__action.Value = 1; //1 is id.
__sitetype.Value = "google.com";
但是这给了我一个“DataGridViewComboBoxCell无效值”的错误。我该如何解决这个问题?
答案 0 :(得分:2)
DataGridViewRow dr = new DataGridViewRow();
DataGridViewCell dcDescription = new DataGridViewTextBoxCell();
dcDescription.Value = "some text";
dr.Cells.Add(dcDescription);
dataGridViewDoctorEventsAddServices.Rows.Add(dr);