简体   繁体   中英

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. On the other hand if I bind it with BindingSource it does the JOB.

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()。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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