Doing calculation in a datagrid

  • Thread starter Thread starter Belee
  • Start date Start date
B

Belee

I have a datagrid on a windows form and I want to multiply
one column by another and the result in another. For
instance multiplying the price column by the quantity
column and updating the amount column. Sample code would
make me happy. Thanks.
 
One way would be to to set the expression of the column you want the result
in
ei: columnResult.Expression = "column1 + column2);
 
Belee said:
I have a datagrid on a windows form and I want to multiply
one column by another and the result in another. For
instance multiplying the price column by the quantity
column and updating the amount column. Sample code would
make me happy. Thanks.

The easiest way to do this is to add another column to your DataTable
and set its Expression property to [Field1] * [Field2]. Then you can
just bind another DataGrid column to it.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
Back
Top