15,940,550 members
See more:
hi I had a wpf datagrid view for products which have columns qty price and total when I add one product total will be calculated by qty * price I had a text box which will store sum of total but when I change qty value in textbox is not changed until and unless it loses its focus from qty kindly help

What I have tried:

decimal total= 0;

for (int i = 0; i < dgvProducts.Items.Count; i++)
{
BLProducts blpro = dgvProducts.Items[i] as BLProducts;
total+= blpro.qty * blpro.price;
}

txtproductTotal.Text = Parsing.ParsetoRound(total, CommonVariables.DecimalPlaces);

I had used this method in celleditending
Posted
Updated 16-Aug-16 11:21am
Maciej Los 16-Aug-16 8:04am
Sorry, but your question is not clear! Please, be more specific and provide more details about your issue...
Member 12346239 16-Aug-16 9:39am
For quantity which control you used textBox or dropDown ?
girishmdr 16-Aug-16 10:02am
qty,price and total are in datagrid and a textbox which shows the sum of every product outside the grid.qty is a datgrid textboxcolumn

## Solution 1

If i understand you well, especially this statement:
girishmdr[^] wrote:
(...) when I change qty value in textbox is not changed until and unless it loses its focus from qty

This is normal behviour of WPF controls. Please read this: Routed Events Overview[^] - WPF Input Events part to find out why.

girishmdr 17-Aug-16 3:09am
Ok I will explain about my question..

I had a datagrid which contains columns qty price and total

when I add one product it will have a price fetched from db say Rs.100
I give qty as 5 so total will be 500

when I add other product having price Rs.150 and I give qty as 4 total will be 600.

These all things happening in gridview and the grant total(textbox outside) will be calculating sum of total(gridview total) ie 500+600=1100

I need that 1100 or whatever when I change the qty in the datagridview itself..

kindly help me..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Top Experts
Last 24hrsThis month
 Pete O'Hanlon 60 Graeme_Grant 40 Wendelius 25 Richard Deeming 25 Lee Zeitz 2024 19
 OriginalGriff 790 Pete O'Hanlon 785 Richard Deeming 715 merano99 335 Dave Kreskowiak 215

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900