0

如何在 datagridview 中将组合框与 LIST<> 绑定。对于绑定“组合框”在这里我直接在绑定源中分配值。

 programEntityBindingSource.DataSource = _Usercom.GetProgramName();

我怎样才能做到这一点

4

1 回答 1

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!
}
于 2013-05-02T05:26:43.337 回答