1,105,295 Community Members

In vb.net ,how to sum column values and put it in a textbox of same page

Member Avatar
nav234
Newbie Poster
2 posts since Mar 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

MY DATAGRID

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

Naveen.....

Member Avatar
Oxiegen
Master Poster
765 posts since Jun 2006
Reputation Points: 88 [?]
Q&As Helped to Solve: 149 [?]
Skill Endorsements: 7 [?]
Featured
 
0
 

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")
Next

TextBox.Text = totalSum.ToString()
Member Avatar
nav234
Newbie Poster
2 posts since Mar 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Thank You Oxiegen ,

I got exactly wat i wanted

Question Answered as of 4 Years Ago by Oxiegen
Member Avatar
awmantonio
Newbie Poster
8 posts since Sep 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
asjedshah
Newbie Poster
1 post since Aug 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

thanks alot its helpful

Member Avatar
ImZick
Posting Whiz in Training
201 posts since Dec 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 4 [?]
Skill Endorsements: 4 [?]
 
0
 

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

N.E.Y.O-01
Newbie Poster
3 posts since Jan 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
Unverified Member
 
0
 

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..... :)

123mahesh
Newbie Poster
1 post since Dec 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
Unverified Member
 
0
 

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

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: