Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Get all data from a column in a datagridview

Posted on 2007-07-26
8
Medium Priority
?
201 Views
Last Modified: 2013-11-26
Hi..

How do I get all data from a column in a datagridview
I want to calulate the total amount in one column
0
Comment
Question by:AWestEng
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 53

Accepted Solution

by:
Dhaest earned 800 total points
ID: 19577795
Do you want to show data from a database into a datagrid ?
http://www.awprofessional.com/articles/article.asp?p=446453
0
 
LVL 27

Assisted Solution

by:planocz
planocz earned 600 total points
ID: 19577838
HI AWestEng,
Check this link it has colunm totals
http://www.timvw.be/developing-a-datasource-for-your-datagridview/
0
 
LVL 48

Assisted Solution

by:jpaulino
jpaulino earned 600 total points
ID: 19577841
You can ...

Dim total As Integer
For x As Integer = 0 To (MyDataGridView.Rows.Count-1)
   total = total + CType(MyDataGridView.Rows(x).Cells(YourColumnIndex).Value, Integer)
Next x
Debug.Print(total)
0
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 
LVL 48

Expert Comment

by:jpaulino
ID: 19577851
I think that AWestEng just wants the total in a variable!
0
 
LVL 18

Expert Comment

by:vbturbo
ID: 19577858
Hi,

you can use the DataColumn.Expression Property which also provide aggregation and sum's collumns

http://msdn2.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx

if you're working with DataTables, you can perform aggregate function over its rows. For example, table.Compute("sum(price)", "") would calculate the sum on all rows over price column in your DataTable.

as shown here

dim myvalue as Object
myvalue = dsSale.Tables("Grid").Compute("Sum(columnToBeCalulated)", "")

should give the total(sum of all rows) in that column.


vbturbo
0
 
LVL 1

Author Comment

by:AWestEng
ID: 19577859
thx guys.. :)
0
 
LVL 1

Author Comment

by:AWestEng
ID: 19577867
ops I was to fast vbturbo:, did not see you message sorry.
0
 
LVL 18

Expert Comment

by:vbturbo
ID: 19577893
No problem

Just glad you solved it -:)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month15 days, 2 hours left to enroll

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question