When using an object-relational binding with the TreeView control, if the DataSource is set to something, set to null and then set to something again the tree will no longer update.
Here is a code sample:
1. Click Load - the base data appears in the tree.
2. Click Add - a new node appear in the tree.
3. Click Clear - all nodes are erased.
4. Click Load - base data is added back in and appears
5. Click Add - nothing happens...
Here is a code sample:
1. Click Load - the base data appears in the tree.
2. Click Add - a new node appear in the tree.
3. Click Clear - all nodes are erased.
4. Click Load - base data is added back in and appears
5. Click Add - nothing happens...
public partial class Form1 : Form { BindingList<Thing> RootChildren; int currentId = 1; public Form1() { InitializeComponent(); } private void buttonLoad_Click(object sender, EventArgs e) { radTreeView1.DataSource = null; RootChildren = new BindingList<Thing>(); Thing t1 = new Thing(1, "One"); Thing t2 = new Thing(2, "Two"); Thing t3 = new Thing(3, "Three"); Thing t4 = new Thing(4, "Four"); currentId = 5; RootChildren.Add(t1); RootChildren.Add(t2); RootChildren.Add(t3); RootChildren.Add(t4); radTreeView1.DataSource = RootChildren; radTreeView1.ChildMember = @"Children\Children\Children\Children"; radTreeView1.ValueMember = "Id"; radTreeView1.DisplayMember = "Name"; } private void buttonClear_Click(object sender, EventArgs e) { radTreeView1.DataSource = null; } private void buttonAdd_Click(object sender, EventArgs e) { Thing thing = new Thing(currentId, "NewThing" + currentId); RootChildren.Add(thing); currentId++; RootChildren.ResetBindings(); } } public class Thing { public int Id { get; set; } public string Name { get; set; } public BindingList<Thing> Children = new BindingList<Thing>(); public Thing() { } public Thing(int id, string name) { Id = id; Name = name; } }