第一种:dataGridView.DataSource = null;
第二种: while (this.dataGridView.Rows.Count != 0)
{
this.dataGridView.Rows.RemoveAt(0);
}
本文介绍两种有效的方法来清除DataGridView中的所有数据。第一种方法是通过设置DataGridView的DataSource属性为null;第二种方法是使用while循环逐行删除,直到DataGridView为空。
第一种:dataGridView.DataSource = null;
第二种: while (this.dataGridView.Rows.Count != 0)
{
this.dataGridView.Rows.RemoveAt(0);
}
6241

被折叠的 条评论
为什么被折叠?