简体   繁体   English

DataGridView即使在DATASOURCE中有数据也不会显示数据

[英]DataGridView not displaying data even if it has data in DATASOURCE

I bind my DatagridView with BindingList and the datagridview has my data in the DataSource property but I am not sure why it isn't displaying it. 我将我的DatagridView与BindingList绑定在一起,并且datagridview在DataSource属性中具有我的数据,但是我不确定为什么它不显示它。 On the other hand if I bind it with BindingSource it does the JOB. 另一方面,如果我将其与BindingSource绑定,它将执行作业。

I declared the properties in this manner 我以这种方式声明了属性

public string abc { get; set; }

Hey try this code. 嘿试试这个代码。

var list = new List<EmpList>()
{
new Person { Name = "Neeraj", },
new Person { Name = "Dubey", },
};
var bindingEmplist = new BindingList<EmpList>(list);
var source = new BindingSource(bindingEmplist , null);
grid.DataSource = source;

Refer this one for reference Link 请参阅此链接以获取参考链接

您可能需要在更改属性的类中实现INotifyPropertyChanged,此外,每当DataGrid更新其视图时,都要调用NotifyPropertyChanged()。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM