I'm filling my DataGridView with a list of objects, however, when I fill in the grid for the first time everything is fine. When I remove the DataSource property as null, the grid columns are deleted.
Is it possible to reset the DataSource property without deleting the columns of the header?
Code snippet that I use:
if (listVetObj.Count > 0)
{
dgvControle.DataSource = listVetObj;
dgvControle.Update();
dgvControle.Refresh();
txtQtdeLinhas.Text = dgvControle.RowCount.ToString();
txtQtdeLinhas.Refresh();
}
When I reset the property within a method the header columns are deleted:
Code:
private void LimparCampos()
{
dgvControle.DataSource = null;
dgvControle.Update();
dgvControle.Refresh();
}