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

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.

commented: Cool. +6
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.