如何在 C#中绑定List<>
到?DatagridView
List<Item> itemList = new List<Item>();
应该看起来像这样:
var bs = new BindingSource();
var list = new List<YourType> { ... };
bs.DataSource = list;
grid.DataSource = bs;
它应该工作
BindingList<MyList> Categories = new BindingList<MyList>();
Categories.Add(new MyList("Hello"));
dataGridView1.DataSource = Categories;
您可以像这样简单地绑定它
List<object> itemList = new List<object>();
grid.DataSource = itemList;
grid.DataBind();