Hi all,

Iam using vb.net and WPF
In a wpf window im showing a datagrid in the load event
while in the load event itself,i need to count grand total
amount from a single datagrid column and add it to a
textbox in same page .

My page looks like this


Item Quantity Total
`````` ```````` `````
Shirt 2 200
Pant 1 500
Tie - -
Belt 2 100

MY TEXTBOX ---> Grand Total amount : - 800

How do i do tat if iam counting from a ((Total Column )) DTG
and adding it and showing it in my (( GRAND TOTAL AMOUNT)) TEXTBOX

Thanks in advance


Recommended Answers

All 7 Replies

Wouldn't it be easier to look at the underlying datasource?
For example, if the DataGrid is bound to a DataSet you can loop that to find the values you are looking for.

Dim totalSum As Integer

For i As Integer = 0 To DataSet.Tables(0).Rows.Count - 1
   totalSum += DataSet.Tables(0).Rows(i).Item("Total")

TextBox.Text = totalSum.ToString()

Thank You Oxiegen ,

I got exactly wat i wanted

What about if using a listview instead of datagrid? Thanks in advance...

thanks alot its helpful

I just posted a new tread about this but after seeing this one my problem is solved thanks :) Thanks @Oxiegen

What if, "I would like to create a query statement that would give me the sum of the column(total_bill)?"
like this:

("Select SUM(total_bill)FROM tbl_estimates WHERE estimation_date = '"& Textbox1.Text & "'",2)

I would like to Display it in my listview.

My, Query statement is absolutely right, but then there is still an error that doesnt have a suggestion.

Maybe you guys could help me..... :)

hey man i was wondering for the solution of this since long time >>>>>>>> i really got pleased thnks man

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.