简体   繁体   中英

Check if a new row is added to a DataGridView

I download data from my server and use a DataGridView to present the result. When a new row is added, I'd like my program to show a signal. How can I do that?

Subscribe to the DataGridView.RowsAdded event.

dataGridView1.RowsAdded += new DataGridViewRowsAddedEventHandler(dataGridView1_RowsAdded);

void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
{
    // show the signal
}

You need to use userAddedRow event , when activate that event you can use it to send boolean like true or false like this Example

 private void usersDGV_UserAddedRow(object sender, DataGridViewRowEventArgs e)
  {
     //this event occurs when user added new row to the datagridview 
     //and will turn the boolean newRowAdded on.
           newRowAdded = true;
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM