绑定到 datatable 增加行时 会自动增加
//数据源
DataTable yourDataTable=new DataTable();
// 添加两列
yourDataTable.Columns.Add("Column1", typeof(string));
yourDataTable.Columns.Add("Column2", typeof(string));
添加一行数据
yourDataTable.Rows.Add("Value1", "yu");
// 将 DataTable 设置为 DataGridView 的数据源
GridView.DataSource = yourDataTable;
// 创建一个新的DataRow
DataRow newRow = yourDataTable.NewRow();
// 假设有两列,分别为 "Column1" 和 "Column2"
newRow["Column1"] = "Value1";
newRow["Column2"] = "Value2";
// 将新行添加到数据源
yourDataTable.Rows.Add(newRow);