1 List<Person> list=new List<Person>();
 2 
 3 for(int i=0;i<10;i++)
 4 
 5 {
 6 
 7   list.Add(new Person(){........})
 8 
 9 }
10 
11 dgvPerson.DataSource=list;
12 
13 //到此,dgvPerson会显示list的内容,但是继续执行下面代码的时候,dgvPerson不会显示新的list内容
14 
15 list.Clear();
16 
17 for(int i=0;i<10;i++)
18 
19 {
20 
21   list.Add(new Person(){........})
22 
23 }
24 
25 dgvPerson.DataSource=list;
26 
27 //这里如果把List改为BindingList,则可以很好的解决此问题。

 

相关文章:

  • 2021-12-07
  • 2021-09-27
  • 2021-09-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-24
  • 2022-12-23
  • 2021-07-19
  • 2021-08-07
  • 2021-11-27
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案