【发布时间】:2015-03-19 09:47:58
【问题描述】:
我有一个 DataGridView 并希望在我在该特定列中输入值时使用行的总和更新一个标签(逐行)。它基本上是一个发票生成gridView。当我在网格视图中输入商品价格时,我需要不断更新总金额标签。我正在尝试使用 cellLeave 事件,因为我希望在离开单元格并进入下一行后立即更新金额。但是事件没有触发..真的需要帮助! 我正在使用此代码:
private void dataGridView1_CellLeave(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 2)
{
Double result = 0;
foreach (DataGridViewRow row in this.dataGridView1.Rows)
{
result += Convert.ToDouble(row.Cells[2].Value);
}
this.label3.Text = result.ToString();
}
}
【问题讨论】:
-
事件未触发或您的代码不起作用?
-
事件没有触发。我的意思是如果我输入值,标签不会更新。
-
输入值并离开单元格?事件挂了?
-
你试过放置消息框或断点吗?
-
@TaW:是的,输入值并离开单元格。事件挂钩意味着什么?
标签: c# datagridview