如何绑定datagridview组合框excell并添加valuemember和displaymember



Hiii to all,

我正在用VB.NET和C#开发桌面应用程序,我已经掌握了简单页面CRUD应用程序的所有概念,现在我正在开发具有主事务表概念的页面,我需要在datagridview中绑定组合框,但我不知道如何做到这一点,

因此,任何关于这个主题的帮助都将不胜感激,

提前感谢

如果你有DataGridViewComboBoxColumn,那么要将该列中的每个ComboBoxCell绑定到给定的数据源,你可以这样做:

private void Bind(ICollection<YourObject> source)
{
     //assume col is the combobox column
     col.DisplayMember = "Name";  //name of property that will be displayed in combo box
     col.ValueMember = "Id";      
     col.DataSource = source;
}

就是这样:)。

最新更新