?
Solved

Is it possible to make math calculations between 2 columns in datagridview?

Posted on 2006-04-08
5
Medium Priority
?
548 Views
Last Modified: 2008-03-17
I have upgraded to VS2005 (what a difference a day makes!!!!). When I have datatable info presented to the user in a datagridview, is it possible to make math calculations (such as addition and subtraction) between 2 columns in that same datagridview while in the datagridview?  When I enter a number in one column I want it to subtract it  (after coding a button) from another column within that same datagridview.

Thanks
0
Comment
Question by:grouchyfd
  • 3
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
CDCOP earned 2000 total points
ID: 16408030
I've haven't used datasets in VS.NET yet, but im guessing something like:

Dim dg As DataGrid
Dim intValue As Integer

'dg.Item(1, 0) = dg.item(rowindex,columnindex)
intValue = CType(dg.Item(1, 0), Integer) + CType(dg.Item(1, 1), Integer)
0
 

Author Comment

by:grouchyfd
ID: 16409365
So I convert the datatype by CType and then specify (row index, column index) for each exact record in the column I want to add togetther? If this makes the chage in the datagridview, I can push the update into the database.
0
 
LVL 9

Expert Comment

by:CDCOP
ID: 16409579
I would play with it and see if it gives you the result you expect. You should be able to push the change back to the DB.
0
 

Author Comment

by:grouchyfd
ID: 16413772
Thank you for your help.
0
 
LVL 9

Expert Comment

by:CDCOP
ID: 16418530
No problem. Thanks for points and grade.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses

621 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