0

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.

thanx

3
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by CodeWord
0

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

100 * 10 / 100 = 10

1

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
Cool.
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.