我想从用户选择的行开始清除 datagridview。我正在尝试几种方法来实现它,但它们都会产生一些错误,现在我有这样的东西:
foreach(DataGridViewRow row in this.dataGridView1.Rows)
{
if(row.Index >= odelementu - 1)
dataGridView1.Rows.RemoveAt(row.Index);
}
用户需要从哪一行中选择我们应该清除datagridview,然后单击按钮
odelementu //this variable represents the starting row
我不知道为什么循环会丢失一些行。我将不胜感激任何建议