| View previous topic :: View next topic |
| Author |
Message |
zaczac Master Cheater
Reputation: 0
Joined: 01 May 2007 Posts: 266 Location: Ontario, Canada
|
Posted: Tue Dec 06, 2011 10:10 pm Post subject: C# ListView questions. |
|
|
Just wanted to know how I would go about taking multiple values in a ListView and performing a calculation with them. Right now the ListView accepts up to 40 rows of data from the user.. each row contains a value for "hours" and "grade. I need to multiply the hours by grade for each row then divide that number by the total amount of rows filled. Heres a small example.
Subject____Hours___Grade
MATH_____11______4
COMM____11______4.5
DBAS_____9_______3
GNED_____8 _______5
If those are the values in the ListView I would need to do the calculation for those + each time a new row is added the final result is updated.
11 x 4 = 44
11 x 4.5 = 49.5
9 x 3 = 81
8 x 5 = 40
total points = 214.5
final result = total points / number of rows
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
|
| Back to top |
|
 |
zaczac Master Cheater
Reputation: 0
Joined: 01 May 2007 Posts: 266 Location: Ontario, Canada
|
Posted: Wed Dec 07, 2011 11:51 am Post subject: |
|
|
How would I go about multiplying the hours and GPA columns together for each row... Could you show me an example (code) what it would look like.
| Description: |
|
| Filesize: |
10.95 KB |
| Viewed: |
8642 Time(s) |

|
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
|
| Back to top |
|
 |
zaczac Master Cheater
Reputation: 0
Joined: 01 May 2007 Posts: 266 Location: Ontario, Canada
|
Posted: Wed Dec 07, 2011 2:34 pm Post subject: |
|
|
Alright that worked but the first value is always 0...
^^ Fixed that ^^
Now I need to limit the amount of items in the viewlist to 40.
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Wed Dec 07, 2011 4:46 pm Post subject: |
|
|
Inside your 'Add' button call at the top, check if the listView1.Items.Count == 40, if it is just exit the function.
_________________
- Retired. |
|
| Back to top |
|
 |
zaczac Master Cheater
Reputation: 0
Joined: 01 May 2007 Posts: 266 Location: Ontario, Canada
|
Posted: Wed Dec 07, 2011 5:33 pm Post subject: |
|
|
| Solved all the problems, Thanks a ton wiccaan
|
|
| Back to top |
|
 |
|