Reputation: 43
I used MS-Access
to fill DataGridView
in my C#
Windows Form Application. When i query datas from Access database it displays correctly. But when i press the view data button again it adds empty columns. This process repeats. I used
dataGridView1.DataSource = null;
dataGridView1.Rows.Clear();
dataGridView1.Refresh();
to clear DataGridView
but no luck.
Upvotes: 0
Views: 22163
Reputation: 7696
You can also clear what the DataSource
is bound to or do the following:
dataGridView1.DataSource = null;
dataGridView1.DataBind();
See https://www.codeproject.com/Questions/332902/how-to-clear-datagridview-in-csharp
Or,
Upvotes: 0
Reputation: 8224
From the comments on the original question:
Try clearing the columns as well
dataGridView1.Columns.Clear();
Upvotes: 6