当我对第一个datagridview1数据进行更改时,我想复制,然后只想将更改后的行数据从datagridview1复制到datagridview2
private void button1_Click(object sender, EventArgs e) {
string query = @"Select Item.ItemName as item, Stock.SalePrice as
Price, invoice.Qty
FROM invoice
JOIN item ON invoice.ItemID = item.ItemID
JOIN sale ON invoice.SaleID = sale.SaleID
join Stock on Stock.ItemID = item.ItemID
where sale.SaleID = '" + textBox1.Text + "'";
SqlDataAdapter SDA = new SqlDataAdapter(query, con);
DataTable dt = new DataTable();
SDA.Fill(dt);
dataGridView1.DataSource = dt;
DataGridViewButtonColumn btn = new DataGridViewButtonColumn();
dataGridView1.Columns.Add(btn);
btn.HeaderText = "Update";
btn.Text = "Update";
btn.Name = "btnUpdate";
btn.UseColumnTextForButtonValue = true;
}
我称之为单元格值更改事件,但该代码仅复制已编辑的行。
请提供我代码:
答案 0 :(得分:0)
在CellValueChanged
的{{1}}事件中尝试此操作,
datagGridview1
希望这对您有帮助...