C#关于ListBox绑定list,不会刷新数据的问题

定义了一个

public List<string> listIPAndLine = new List<string>();

然后赋值给

listBox1.DataSource = listIPAndLine;

初次显示没有什么问题,但是当listIPAndLine重新更新数据之后,再重新赋值

listBox1.DataSource = listIPAndLine;

页面上的listBox1并没有发什么改变;

最终解决问题的方案:

BindingSource bs = new BindingSource();
bs.DataSource = listIPAndLine;
listBox1.DataSource = bs;

原文地址:https://www.cnblogs.com/PingPo/p/12868107.html