0

我有DataGridViewComboBoxColumn我的datagridview,我想linq在运行时填充使用:

我试试这个

var line = from li in dbdata.Production_lines select li;
grdEmp.Rows.Add();

(grdEmp.Rows[count].Cells["Line"] as DataGridViewComboBoxCell).DataSource = line;
(grdEmp.Rows[count].Cells["Line"] as DataGridViewComboBoxCell).ValueMember = "L_id";
(grdEmp.Rows[count].Cells["Line"] as DataGridViewComboBoxCell).DisplayMember = "L_id";

但这没有用。那么如何将数据绑定到ComboBox我的DataGridView

4

1 回答 1

0

尝试这个 :

DataGridViewComboBoxColumn combo = (DataGridViewComboBoxColumn)grdEmp.Columns["Line"];

combo.DataSource = line;
combo.ValueMember = "L_id";
combo.DisplayMember = "L_id"; // I also suspect this should be a text column
于 2013-02-10T08:01:32.813 回答