用户删除后如何从DataGridview中获取行数据
How to get row data from DataGridview after user deleting it
我在一家商店的项目中工作,使用 DataGridView 存储所有客户订单并不断更新总价。当他轻松订购更多商品时,我会更新价格。当我删除一个特定的项目时,我需要知道它的数据来更新总价。
所以我需要该行的内容来进行我需要的更改。
这就是我在他添加更多商品时用来更新总价的方法:
DataGridViewRow row = new DataGridViewRow();
row.CreateCells(pill);
row.Cells[2].Value = name;
row.Cells[1].Value = price;
row.Cells[0].Value = quantity;
pill.Rows.Add(row);
totalPrice += price * quantity;
total.Text = totalPrice.ToString();
有一个名为 UserDeletingRow
的活动。它接受 DataGridViewRowCancelEventArgs
,其中包含用户删除的行。
您需要做的是订阅此活动,并从那里更新您的价格。
我在一家商店的项目中工作,使用 DataGridView 存储所有客户订单并不断更新总价。当他轻松订购更多商品时,我会更新价格。当我删除一个特定的项目时,我需要知道它的数据来更新总价。
所以我需要该行的内容来进行我需要的更改。
这就是我在他添加更多商品时用来更新总价的方法:
DataGridViewRow row = new DataGridViewRow();
row.CreateCells(pill);
row.Cells[2].Value = name;
row.Cells[1].Value = price;
row.Cells[0].Value = quantity;
pill.Rows.Add(row);
totalPrice += price * quantity;
total.Text = totalPrice.ToString();
有一个名为 UserDeletingRow
的活动。它接受 DataGridViewRowCancelEventArgs
,其中包含用户删除的行。
您需要做的是订阅此活动,并从那里更新您的价格。