如何将组合框与LIST<>结合?在datagridview中。绑定'Combobox' 在这里,我直接在绑定源中分配值。
programEntityBindingSource.DataSource = _Usercom.GetProgramName();
我该怎么做
答案 0 :(得分:1)
您必须遍历datagridview行并按如下方式将其逐个绑定,
foreach (DataGridViewRow row in myDataGridViewProducts.Rows)
{
DataGridViewComboBoxCell cell =DataGridViewComboBoxCell)row.Cells("myProductCol");
cell.DataSource = _Usercom.GetProgramName();
cell.DataPropertyName = "ProgramName";
cell.DisplayMember = "Name";
cell.ValueMember = "Self"; // key to getting the databinding to work
// no need to set cell.Value anymore!
}