Monday, August 16, 2010

How to do an autocalculation in vb.net using an datagrid?

i am programming in datagrid there i have to do an autocalculation for eg in an row tere is an discount percent and actual price is there after entering the both when i use tab to price it should calculate and should have showHow to do an autocalculation in vb.net using an datagrid?
You have to add a new column to the data table and set its 'Expression' property.





eg.


Assuming that the datatable is dtTable, name of discount column is ';Discount'; and name of price column is ';Price';





dtTable.Columns.Add(';Price After Discount';, GetType(System.Single), ';[Price] * (100 - [Discount]) / 100';)





or alternatively





dtTable.Columns(';Price After Discount';).Expression = ';[Price] * (100 - [Discount]) / 100';

No comments:

Post a Comment