Home › Forums › WinForms controls › Xceed Grid for WinForms › Calculation › Reply To: Calculation
Yes it is. Here’s an example of how to do this (untested code):<code>EventHandler handler = new EventHandler(CalculateTotal);
myGrid.DataRowTemplate.Cells[“Price”].ValueChanged += handler;
myGrid.DataRowTemplate.Cells[“Quantity”].ValueChanged += handler;
private void CalculateTotal(object sender, EventArgs e) {
Cell cell = sender as Cell;
if (cell == null) return;
CellRow row = cell.ParentRow;
double price, quantity;
object o = row.Cells[“Price”].Value;
if (o is double) price = (double)o; else price = 0.0;
o = row.Cells[“Quantity”].Value;
if (o is double) quantity = (double)o; else quantity = 0.0;
row.Cells[“Total”].Value = price * quantity;
}</code>
Imported from legacy forums. Posted by Tommy (had 382 views)