我用下面的方法來建立數據源:如何在C#中的Datagridview中添加新行?
BindingList<Person> people = new BindingList<Person>();
foreach (var tag in names)
{
people.Add(new Person
{
Id = tag.ID,
Name = tag.Name,
Tag = tag.Ref
});
}
dataGridView1.DataSource = people;
如何在這個GridView中添加一個新行?
我想這一點,但它重新裝載所有的數據:
BindingList<Person> people = new BindingList<Person>();
//set datagridview datasource
dataGridView1.DataSource = people;
//add new product, named Cookie, to list ant boom you'll see it in your datagridview
people.Add(new Person());
dataGridView1.DataSource = people;
添加Person'類的'另一個實例'人列表並重新綁定。這是Windows窗體應用程序? – Nino
你能看到我的更新嗎? – SFSFSFSF
是的,我可以。薄winForms應用程序?在哪個事件中你填充DataGridView? – Nino