RDP0 yeni = new RDP0();
yeni.IPADDRESS = "1.1.1.1";
yeni.PASSWORD = " 10akh0";
yeni.NO = 8;
yeni.CUSTID = 1000;
testList.Add(yeni);
dataGridView1.DataSource = testList;
我收到了数据绑定错误,因此我无法添加行。任何帮助都会很棒。 这就是我将数据绑定到dataGV的方式:
tm = new testModel();
var query = from fe in tm.ERDP0 select fe;
testList = query.ToList();
dataGridView1.DataSource = testList;
答案 0 :(得分:1)
如果DataGridView
是数据绑定,则无法直接向DataGridView
添加新行/列。但您可以向DataTable
添加一行,这会自动更新您的DataGridView
。
DataTable dt = dataGridView1.DataSource as DataTable;
dt.Rows.Add("new row");
或者您可以将新行添加到源列表,然后重置DataSource:
testList.Add(youritem);
dataGridView1.DataSource = null;
dataGridView1.DataSource = testList;