VB.NET:清除DataGridView [英] VB.NET: Clear DataGridView
问题描述
我已经尝试了 -
DataGridView1.DataSource = Nothing
和
DataGridView1.DataSource = Nothing
DataGridView1.Refresh()
和
DataGridView1.RefreshEdit()
/ p>
我写了一个方法来设置DataGridView的DataSource在执行时。但是每次执行它时,它会将数据复制到新的值中,并将其附加到DGV的前一个内容中。我想要清除内容,然后添加值..这是可能吗?
如果DataGridView绑定到任何数据源,则必须将DataGridView的 DataSource
属性设置为
如果DataGridView没有绑定到任何数据源,这个代码将会做到这一点: p>
DataGridView.Rows.Clear()
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?
If the DataGridView is bound to any datasource, you'll have to set the DataGridView's DataSource
property to Nothing
.
If the DataGridView is not bound to any data source, this code will do the trick:
DataGridView.Rows.Clear()
这篇关于VB.NET:清除DataGridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!