|
-
Dec 13th, 2010, 06:55 AM
#1
Thread Starter
Junior Member
Subtract column values in listview
Hi, I have a 3 column listview. Column 1 and 2 has few integer. How can I subtract Column 1 and column and show the result in column 3. Below is a sample data for columns.

Please help me to solve this problem.
Thanks
-
Dec 13th, 2010, 09:47 AM
#2
Re: Subtract column values in listview
You loop through the Items collection of the ListView. For each item, you index the Subitems collection to access each subitem. You get the Text of the first two subitems, convert each one to a number, perform your calculation, convert the result to a String and then assign that to the Text of the third subitem.
-
Dec 13th, 2010, 01:17 PM
#3
Thread Starter
Junior Member
Re: Subtract column values in listview
Hi, thanks for your reply. Can you plz show me code because I am not sure how to loop through the listview items and perform calculation.
Thanks
-
Dec 13th, 2010, 06:32 PM
#4
Re: Subtract column values in listview
I'm fairly certain that there would be at least one example of looping through the items in a ListView already on the web. Look first, ask questions later.
-
Dec 13th, 2010, 08:46 PM
#5
Thread Starter
Junior Member
Re: Subtract column values in listview
Thanks again for your generosity, I am here having problem with calculating one column from another. I have searched on the net(I always search first) and the kind of problem I am having here not available with working solution. Thats why I asked here.
-
Dec 13th, 2010, 09:22 PM
#6
Re: Subtract column values in listview
Your problem, like so many people, is that you're looking for code that does exactly what you want. That is often not possible, but that doesn't mean that you can't find relevant examples. Look back at my first post. Do you see how I broke the problem up into steps? It would be quite easy to find example code for each of those steps on the web. You may not find a single example that does all of them but you don't need that. All you need is to determine how to perform each step individually. Once you can do that, it's a simple matter of putting the pieces together.
So, start at the first step and forget everything else for now.
You loop through the Items collection of the ListView.
Show us your code to do just that. As I implied earlier, you should be able to find plenty of examples. What each of those examples actually does inside the loop is not relevant at this stage.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|