I have a datagridview bound from a datatable. I have a calculated column linetotal that multiples unitprice * quantity.
I also have a totalprice label,that I would like to contain the sum of the linetotal column in the datagridview.
When the user makes any changes to unitprice or quantity, the linetotal should update for that line and the totalprice label should sum the linetotal column.
I can't seem to find the correct event to use to calculate the totalprice label. I've tried cellvaluechanged, currentcelldirtystatechanged, rowleave. None of them seems to work right. I guess I need an event that fires after all the linetotal columns are calculated.
My pseudocode:
dt = getallitems(itemnumber);
dt.Columns.Add("LineTotal", typeof(double));
dt.Columns["Linetotal"].Expression = "[unitprice] * [quantity]";
dgv.DataSource = dt;
private void dgv_WhatEventToUse???(object sender, DataGridViewCellEventArgs e)
{
//method to iterate the rows of the datagridview, and sum linetotal column
}
There must be some event that fires when the value of the calculated column is changed.