检查是否有新行添加到DataGridView

时间:2014-03-11 02:38:15

标签: mysql vb.net winforms datagridview

我从服务器下载数据并使用DataGridView来显示结果。当添加新行时,我希望我的程序显示信号。我怎么能这样做?

2 个答案:

答案 0 :(得分:1)

订阅DataGridView.RowsAdded活动。

dataGridView1.RowsAdded += new DataGridViewRowsAddedEventHandler(dataGridView1_RowsAdded);

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

答案 1 :(得分:0)

您需要使用userAddedRow事件,当激活该事件时,您可以使用它来发送 布尔值,如本例一样,为true或false

 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;
  }