Solved

C# DataGridView_RowsAdded event not firing

Posted on 2016-11-19
1
36 Views
Last Modified: 2016-11-20
In a Windows Form I have a datagridview with a bindingsource.
The binding source connects to an external device that adds rows data each 1/20 sec.
Changes of the data are well displayed on the screen (within the datagridview)  but the DataGridView_RowsAdded in the code behind does not fire .
I am unable to understand why.
 
public void dgvvNodes_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
        {         
   
            string searchValueLA = "LeftArm";
            int rowIndexLA = -1;
            Node nodeLA;

            foreach (DataGridViewRow row in dgvvNodes.Rows)
            {
                    if (dgvvNodes.Rows[e.RowIndex].Cells[5].ToString().Equals(searchValueLA)) // "position" is at index 5 in the last added row
                    {
                        rowIndexLA = row.Index;
                        nodeLA = dgvvNodes.Rows[e.RowIndex].DataBoundItem as Node; // get the object origin of data in the last added row 
                        break;
                    }
            }
}

Open in new window

0
Comment
Question by:Paulagier
1 Comment
 
LVL 32

Accepted Solution

by:
Robberbaron (robr) earned 500 total points
Comment Utility
I believe the rows_added event is only fired when u manually add a row. via the gridview...

the DataBound is the only event that will be able to tell when rows are added by keeping a count of previous rows.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

This article will show, step by step, how to integrate R code into a R Sweave document
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now