Solved

C# DataGridView_RowsAdded event not firing

Posted on 2016-11-19
1
75 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
ID: 41894578
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is about my first experience with programming Arduino.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

809 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