有没有什么办法让新添加的行中的DataGridView? [英] Is there any way to get newly added rows in datagridview?
本文介绍了有没有什么办法让新添加的行中的DataGridView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个数据网格视图,它绑定到自定义集合。 我有这将增加,并在DataGridView中删除行的UI添加删除选项。
I have a datagrid view that is bind to a custom collection. I have add remove options in the UI which will add and delete a row in datagridview.
有没有什么办法让新添加的行中的DataGridView?
Is there any way to get newly added rows in datagridview?
推荐答案
在DataGridView有一个RowAdded事件被触发每一个行添加时间(废话!)。事件参数的类型是:DataGridViewRowsAddedEventArgs其上有一个RowIndex属性,使您能够做这样的事情:
The DataGridView has a RowAdded event that gets triggered every time a Row is added (duh!). The Event args is of type: DataGridViewRowsAddedEventArgs which has a RowIndex property on it which enables you to do something like this:
public Form1()
{
InitializeComponent();
this.dataGridView1.RowsAdded += new DataGridViewRowsAddedEventHandler(dataGridView1_RowsAdded);
}
private void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
{
DataGridViewRow newRow = this.dataGridView1.Rows[e.RowIndex];
}
这篇关于有没有什么办法让新添加的行中的DataGridView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文