Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Clear BindingSource?

Tags:

c#

I have a DevExpress GridControl with BindingSouce. I want to clear a BindingSource and fill it with new data. I do:

var list = new List<MyClass>();
bindingSource.DataSource = list;

//**Do somthing with a data**//

bindingSource.DataSource = listOfMyClassObjects;

And after it i see a big red cross instead my GridControl.
How to clear BindingSource correctly?

like image 422
Kliver Max Avatar asked Apr 29 '26 03:04

Kliver Max


1 Answers

In order to clear the BindingSource of GridControl, you can assign null to it's DataSource before you fill with new data.

bindingSource.DataSource = null;
bindingSource.DataSource = listOfMyClassObjects;

You might also refer to this StackOverflow question.

like image 78
Aung Kaung Hein Avatar answered Apr 30 '26 17:04

Aung Kaung Hein