I've tried -
DataGridView1.DataSource=Nothing
and
DataGridView1.DataSource=Nothing
DataGridView1.Refresh()
and
DataGridView1.RefreshEdit()
None of them works..
I've written a method that sets the DataSource of the DataGridView when executed. but each time i execute it, it replicates the data with new value and appends it to the previous contents of the DGV.. I wanna clear the content and then add the values.. Is that possible?
Follow the easy way like this
assume that
ta
is aDataTable
I've got this code working in a windows form,
When feeding info from an SQL query into a datagridview you can clear the datagridview first before reloading it.
Where I have defined dbDataSet as New DataTable I can do a clear. dbDataSet must be at the start of the form within the Public Class Form
within the code of you Private Sub, place
For unbound cases note that:
leaves the Columns collection in place.
..will remove all the columns and rows. If you are using the DGV unbound, and on next use the columns change, clearing the Rows may not be adequate. For library code clear all the columns before adding columns.
just write this
You should remove the table from dataset if the datagrid is bind to some datatable. Your Gridview will be cleared automatically. No other way.