How can I clear rows in DataGridView with C#?

后端 未结 13 2246
野的像风
野的像风 2020-12-03 18:19

Following Error in this line.

datagridview1.Rows.Clear()

but this line gives error:

Cannot clear this list.

13条回答
  •  无人及你
    2020-12-03 18:23

    private void button_Limpar_Click(object sender, EventArgs e)
    {
        DataTable DT = (DataTable)dataGridView_Cidade.DataSource;
        if (DT != null)
            DT.Clear();
    }
    #endregion
    

提交回复
热议问题