我将数据模型实体添加到名为publishingCompanyEntities
的项目并在我的winform中添加了ComboBox。 但是当我想我的作者名单绑定到我的组合框中数据源已经充满了数据,但cmoAuthors.Items.Count
返回0,但cmoAuthors.DataSource.Count
回报2项组合框数据源和实体框架
publishContext = new publishingCompanyEntities();
cmoAuthors.DataSource = publishContext.Authors;
cmoAuthors.DisplayMember = "FirstName";
尝试调用'cmoAuthors.Invalidate()',然后检查是否更新了'Items.Count'。 – 2013-04-09 09:51:54
不,它返回0,winform中的comboBox也是空的! – 2013-04-09 09:58:42
如果将源更改为:'publishContext.Authors.ToList()' – 2013-04-09 10:01:06