Dear Friends

I am using visual basic 2008 amd creatomg a datagrodview format like below

Product Code | Product Description | Price | Qty | Discount(%) | Total

00001 Biscuits 10 2

00002 Cream 50 2

Now I wnat to get total balance in total column after less discount in percentage with ENTER EVENT proceedure and get the whole total column balance in a textbox i.e Net BalanceTextBox. Please tell me how to calculate discount in percent % and get total in total column and also tell me how to move cursor in next cell instead of bottom row in datagridview.


6 Years
Discussion Span
Last Post by CodeWord

To get a percentage of a value, take the value, multiply it by the percentage value, divide it by 100.

100 * 10 / 100 = 10


To get the sum of a column, assuming you have bound your grid to a datatable, you could do something like this (using the datatable):

Dim dValue as double
dValue = myDataTable.Compute("SUM(<fieldName>)")

If you're using a dataview then:

dvalue = dv.ToTable.Compute("SUM(<fieldName>)")

Then simply assign your textbox.text = dvalue

The way to calculate percentages is in the post above.

Edited by CodeWord: n/a

Votes + Comments
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.