12,457,259 members (54,897 online)
Rate this:
See more:
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"

Any Help will be appreciated....
Posted 16-May-10 19:40pm

Rate this:

## 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```
jleonorlane 17-May-10 3:35am

Rate this:

## 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]);
}```
jleonorlane 17-May-10 3:35am

Sandeep Mewara 17-May-10 3:41am

This was to give you an idea... try out.

Top Experts
Last 24hrsThis month
 OriginalGriff 288 Maciej Los 258 Dave Kreskowiak 148 Mehdi Gholam 145 ppolymorphe 141
 OriginalGriff 6,916 ppolymorphe 4,101 Maciej Los 3,943 Karthik Bangalore 3,665 Richard Deeming 2,915