|
-
Feb 20th, 2018, 08:54 AM
#1
Thread Starter
New Member
Rows collection cannot be programmatically cleared -- Error
Hello All ......
I Have Bound DataGridView and i tried to clear it before get record ihave tried :
And
Code:
DGV.Datasorce=Nothing
And
None Or Then Works iand iam getting this error
Rows collection cannot be programmatically cleared when the DataGridView control is data-bound to anything else than an IBindingList that supports change notification and allows deletion.
Last edited by Salem141; Feb 20th, 2018 at 09:02 AM.
-
Feb 20th, 2018, 09:05 AM
#2
Re: Rows collection cannot be programmatically cleared -- Error
Right... so as long as it is bound, you cannot clear the rows. So you have to do two things. Unbind the DGV, then clear the rows.
-tg
-
Feb 20th, 2018, 09:16 AM
#3
Thread Starter
New Member
Re: Rows collection cannot be programmatically cleared -- Error
Got it ...
Code:
DGV.DataSource = Nothing
DGV.Rows.Clear()
Thanks For Help
-
Feb 21st, 2018, 08:20 PM
#4
Re: Rows collection cannot be programmatically cleared -- Error
If you set the DataSource to Nothing then that should remove the rows automatically. The question is whether setting the DataSource to Nothing is the correct option. It may actually be more appropriate that the grid remains bound and you remove/delete all the rows/items in the data source. We can't really say based on the information provided. Looking at your screenshot though, it looks like you're doing something weird. Why are you adding rows to the grid directly from a DataTable? Why aren't you simply binding that DataTable to the grid?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|