Results 1 to 5 of 5

Thread: sum of filtered rows of datagridview

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2008
    Posts
    36

    sum of filtered rows of datagridview

    Hi,

    I have a datagridview in my application with numeric columns and date column. This datagridview is filtered by date. I want a label to show the sum of the filtered rows.

    Can you help me?

  2. #2
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: sum of filtered rows of datagridview

    Are you binding the DataGridView? How are you filtering the rows?

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2008
    Posts
    36

    Re: sum of filtered rows of datagridview

    Yes I am. Please find below the code:

    Code:
      
        Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
            Dim strData As String
            strData = DateTimePicker1.Text
            Me.CadastroSeqBindingSource.Filter = "Data = '" + strData + "'"
            Me.CadastroSeqTableAdapter.Fill(Me.Db01DataSet.CadastroSeq)
    End Sub
    Thanks

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: sum of filtered rows of datagridview

    E.g.
    vb.net Code:
    1. Dim sum = CInt(Me.Db01DataSet.CadastroSeq.Compute("SUM(SomeColumn)", Me.CadastroSeqBindingSource.Filter)
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Member
    Join Date
    Jul 2008
    Posts
    36

    Resolved Re: sum of filtered rows of datagridview

    Wawww, It works very well, thank you.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width