Friday, January 24, 2014

SUM OF A DATAGRIDVIEW CELL USING LINQ



SAMPLE:1

Dim qry0 = From theRow As DataGridViewRow In dgvData.Rows _
                      Select theRow
Dim t = qry0.Sum(Function(x As DataGridViewRow) x.Cells("Amount").Value)

** dgvData - Datagridview name "Anount" is column name

-----------------------------------------------------------------

SAMPLE:2

Dim qry1 = From theRow As DataGridViewRow In dgvData.Rows _
              Where theRow.Cells("Year").Value > 2010 _
              Select theRow

Dim t = qry1.Sum(Function(x As DataGridViewRow) x.Cells("Amount").Value)


No comments:

Post a Comment