This is a migrated thread and some comments may be shown as answers.

Add new item to generic list datasource not displaying in listview

1 Answer 91 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 07 Dec 2011, 11:02 PM
I have a few listviews, each bound to a generic list of a simple class. When the user clicks a button I want to remove an item from one list and add it to another. I am able to do this just fine but the listview does not refresh it's contents. What is the method required to rebind or reload the bound data?

1 Answer, 1 is accepted

Sort by
0
Ivan Todorov
Telerik team
answered on 08 Dec 2011, 04:10 PM
Hi David,

Thank you for contacting us.

If you are using the generic List class, then you would have to reset RadListView's data source every time you insert or delete items from your list. This can be achieved as it is shown below:
this.radListView1.DataSource = null;
this.radListView1.DataSource = myList;

A better approach is to use BindingList instead of List. The BindingList sends notifications when you modify its contents and RadListView will automatically reflect them.

I hope you find this helpful. In case you have any additional questions, do not hesitate to contact us.

Greetings,
Ivan Todorov
the Telerik team

Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

Tags
General Discussions
Asked by
David
Top achievements
Rank 1
Answers by
Ivan Todorov
Telerik team
Share this question
or