0
如何在datagridview中將組合框與LIST <>綁定。對於綁定'Combobox' 在這裏,我直接分配綁定源中的值。在datagridview中綁定Combobox表單LIST <>
programEntityBindingSource.DataSource = _Usercom.GetProgramName();
我怎樣才能做到這一點
如何在datagridview中將組合框與LIST <>綁定。對於綁定'Combobox' 在這裏,我直接分配綁定源中的值。在datagridview中綁定Combobox表單LIST <>
programEntityBindingSource.DataSource = _Usercom.GetProgramName();
我怎樣才能做到這一點
你必須通過在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!
}
什麼是IProduct這裏和我需要使用此 – Abhishek 2013-05-02 05:27:47
該行不是必需的。現在檢查。 – 2013-05-02 05:28:38
你真的需要循環,你可以將'Datasource'分配給列本身! ! – V4Vendetta 2013-05-02 05:38:22