dcsimg
Results 1 to 3 of 3

Thread: DataGridView Row Count Changed Event?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    190

    DataGridView Row Count Changed Event?

    Aftnoon all,

    I currently have a filtered datagridview with data in it and I'm trying to get a little counter somewhere to show how many rows there are. 'DataGridView.RowCount' will give me the total number of rows, I've been hunting around looking for a 'DataGridView Row Count Changed Event'. Unless i've missed something I'm pretty sure there isn't one, any suggestions how / where I should fire it?

    Thanks

    Dave

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    40,122

    Re: DataGridView Row Count Changed Event?

    A quick look at the documentation for the DataGridView ( https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx ) shows two useful events, RowsAdded ( https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx ) and RowsRemoved (https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx )

    Depending on whether the data comes from binding etc, this may not be the best option available.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    190

    Re: DataGridView Row Count Changed Event?

    Thank you, works perfectly!

    Code:
    Private Sub RowCountEvent(ByVal sender As Object, ByVal e As DataGridViewRowsAddedEventArgs) Handles DataGridView.RowsAdded
            Console.WriteLine("rows added: " & DataGridView.RowCount)
    End Sub
    Last edited by QuattroDave; Apr 16th, 2018 at 02:15 PM. Reason: typo

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width