Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Can anyone help me regarding on how to sum all items in a specific column in listview which is the data type of the column is "DOUBLE or INTEGER"
 
Please help me ....
 
Any Help will be appreciated....
Posted 16-May-10 20:40pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Something like
 
For Each col As DataGridViewColumn In dgvMyDataGrid.Columns
    If col.ValueType Is GetType(Integer) OrElse col.ValueType Is GetType(Double) Then
        Dim sum As Double = 0
        For Each row As DataGridViewRow In dgvMyDataGrids.Rows
            'If the column is visible:
            If row.Cells(col.DisplayIndex).Value IsNot Nothing AndAlso Not IsDBNull(row.Cells(col.DisplayIndex).Value) Then
                sum += Convert.ToDouble(row.Cells(col.DisplayIndex).Value)
            End If
        Next row
    End If
Next col
  Permalink  
Comments
jleonorlane at 17-May-10 3:35am
   
..how about in Listview
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Go for a loop on listitems, get the value of each list item that you are talking of and do any mathematical permutation you want to on them.
 
something like:
// This is in C#
double someValue = 0;
foreach(ListItem li in myList.Items)
{
  // play with someValue
  // you need to put validation checks to make sure the value you 
  // are converting is of correct datatype.
  // This is just a sample code
  someValue += Convert.ToDouble(li[2]);
}
  Permalink  
Comments
jleonorlane at 17-May-10 3:35am
   
how about in VB.NET
Sandeep Mewara at 17-May-10 3:41am
   
This was to give you an idea... try out.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 295
1 DamithSL 295
2 Sergey Alexandrovich Kryukov 197
3 Peter Leow 155
4 Afzaal Ahmad Zeeshan 154
0 OriginalGriff 7,510
1 DamithSL 5,494
2 Sergey Alexandrovich Kryukov 4,954
3 Maciej Los 4,936
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web03 | 2.8.141223.1 | Last Updated 17 May 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100