Jump to content
Xtreme .Net Talk

Recommended Posts

  • *Experts*
Posted
It would be soooo easy to total the results of calculations in 5 different listview columns if I hadn't opted for a clear row function....but I did. The results are now in 5 of the 10 columns Excel spread sheet style. Each column has a specific name i.e. lvwAmps, lvwkW, lvwHP, lvwkVa, and lvwBTU. (this is an electric engery calculator). I do not know how many rows are present at the time the user wants to calculate the totals for these 5 columns. So how do I total the results in the given columns?

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

  • *Experts*
Posted

Thanks for your responce,

 

Yes, they are always the same columns. The first five columns are not required for the addition. And you idea sounds great...could you show an example?

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

  • *Gurus*
Posted

This piece of code adds up all the numbers in the second column on a listview in Details mode.

 

       Dim l As ListViewItem
       Dim count As Integer

       count = 0
       For Each l In ListView1.Items
           count += Integer.Parse(l.SubItems(1).Text)
       Next

       MessageBox.Show(count.ToString())

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

  • *Experts*
Posted

Are you binding your ListView from a DataSet (not even sure if that's possible)? If so, the DataTable supports a Compute method to sum up values all at once.

 

-nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
  • *Experts*
Posted

No nerseus, the listview data is generated from calculations not a dataset. It acutally works very well and feels like Excel, except you cannot edit any of the colmuns except the first. This works very well in this case since the results are used for sizing transformers, circuit breakers, wire gauges, etc. per NFPA-NEC codes and regulations. Any user editing could have disasterious results resulting in lawyers. Pooh on that!

 

This is only my second major project with VB.Net and it is moving slowly but with wonderful results thanks to yourself, divil and the many others on this board.

 

Thanks again!

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...